Gain a deeper understanding of testing and debugging in Ruby, focusing on unit testing frameworks like Minitest and RSpec, as well as essential debugging tools such as byebug and pry. These 30 multiple-choice questions will guide you through essential testing concepts and debugging practices.
before and after hooks in RSpec?
context keyword used for in RSpec?
let keyword used for in RSpec?
byebug?
pry to step through the code line by line?
binding.pry in Ruby?
pry session?
byebug allows you to step through code after a breakpoint?
byebug, what command is used to continue execution after hitting a breakpoint?
pry?
byebug shows the current stack trace?
pry gem?
| Qno | Answer (Option with the text) |
|---|---|
| 1 | C) Both A and B |
| 2 | C) rspec |
| 3 | A) assert_equal |
| 4 | B) rspec |
| 5 | A) it |
| 6 | A) assert_equal |
| 7 | A) describe |
| 8 | A) To execute code before and after each test |
| 9 | B) it “should work” do |
| 10 | A) assert_raises |
| 11 | D) All of the above |
| 12 | A) expect { }.to raise_error |
| 13 | B) Minitest |
| 14 | A) To group related examples based on a common condition |
| 15 | A) expect(value).to eq(expected_value) |
| 16 | A) To simulate the behavior of objects or methods in tests |
| 17 | A) rspec test_spec.rb |
| 18 | B) rspec –init |
| 19 | A) To define variables for test examples |
| 20 | A) include |
| 21 | D) both A and B |
| 22 | A) byebug |
| 23 | B) next |
| 24 | A) It pauses the execution of code and opens an interactive session |
| 25 | C) Ctrl + D |
| 26 | B) next |
| 27 | C) continue |
| 28 | A) pry variable_name |
| 29 | B) where |
| 30 | C) Code coverage reports |