All quizzes
Free quiz · 20 questions in the bank

RSpec quiz

Test your RSpec knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

What is RSpec's "expect" syntax (`expect(x).to matcher`), and how does it differ from the older "should" syntax (`x.should matcher`)?

In this round
  1. What is RSpec's "expect" syntax (`expect(x).to matcher`), and how does it differ from the older "should" syntax (`x.should matcher`)?
  2. What is a `verifying double` (like `instance_double(User)`) in RSpec, and how does it differ from a plain `double`?
  3. What is the purpose of `before(:each)` (or simply `before`) and `after(:each)` in an RSpec spec file?
  4. What is a general criticism sometimes raised about RSpec's highly expressive, English-like DSL syntax compared to a more plain, code-based testing framework like Minitest?
  5. What does `allow(object).to receive(:method_name).and_return(value)` do in RSpec?
  6. What does `expect(array).to include(item)` check in RSpec?
  7. What is a "context" block in RSpec, and how does it differ from `describe`?
  8. What is `described_class` in an RSpec spec, when used inside a `describe SomeClass do ... end` block?
  9. What do `describe` and `it` do in an RSpec spec file?
  10. What is "shared examples" in RSpec, and what problem does it solve?
  11. What does `expect { fn.call }.to raise_error(SomeError)` check in RSpec?
  12. What does `expect(value).to be_truthy` check, versus `expect(value).to eq(true)`?
Gaps to close?
Read the curated RSpec notes — core concepts, patterns, interview prep.
RSpec notes

More quizzes

.NETAccessibilityAgileAgile MethodologyAirflowAkka