Ruby Logo

Testing & Debugging Quiz

Assess your testing toolbox—from frameworks and doubles to coverage, debugging, and observability practices.

Home Ruby Testing & Debugging Quiz

Testing & Debugging Quiz

Put your knowledge of Ruby testing, doubles, coverage, debugging, logging, and observability to the test. Each scenario mirrors decisions you will make while working on RubyDev.

Instructions: Choose the best answer for each question, then review the explanation block. Aim to reason about trade-offs instead of memorising APIs.

1. RSpec or Minitest?

A new feature needs fast feedback in CI and must reuse the existing fixtures defined in `test/fixtures`. Which approach minimises setup friction?

A) Port everything to RSpec for the new feature.
B) Continue with Minitest and add focused tests in `test/services`.
C) Mix both frameworks in the same file.
D) Skip tests—fixtures slow down feedback anyway.

Answer: B — Minitest integrates with fixtures out of the box and requires no extra infrastructure for this feature.

2. Mocking external services

Your service posts analytics to an external API during tests. How do you isolate the suite?

A) Allow the HTTP call to hit the real endpoint.
B) Use WebMock to stub the request and verify payloads.
C) Silence the exception so the spec passes.
D) Wrap the call in `sleep` to avoid hitting rate limits.

Answer: B — WebMock (or VCR) isolates the suite, lets you assert on JSON payloads, and keeps tests deterministic.

3. Coverage thresholds

SimpleCov reports 70% coverage for `app/services/billing`. What is the best next step?

A) Lower the global minimum coverage to 70%.
B) Add targeted tests for billing flows and update docs with the new metric.
C) Delete the coverage report; it slows CI.
D) Disable branch coverage to increase the number.

Answer: B — strengthen tests where it matters and keep thresholds honest.

4. Debugging production issues

You need to debug a production-only bug in a Sidekiq worker. What workflow is safest?

A) Add `binding.pry` and deploy it to production.
B) Use the `debug` gem with a secure SSH tunnel and remove breakpoints immediately after reproducing.
C) Restart Sidekiq repeatedly until the bug disappears.
D) Ignore the issue because it only happens in production.

Answer: B — secure remote debugging provides insight while preserving production safety.

5. Observability signals

Incident response shows slow lesson publish times. Which signal provides the most actionable insight?

A) A tweet complaining about the app.
B) A metric from ActiveSupport::Notifications showing publish latency over time.
C) A random log entry from last month.
D) Re-running the job in production without instrumentation.

Answer: B — instrumentation tied to the workflow exposes trends and correlates with deployments.

Next steps

  • Pair this quiz with `bundle exec rspec --only-failures` or `bin/rails test --seed` to practice debugging failing suites.
  • Wire SimpleCov JSON output into your favourite observability platform and trend coverage by component.
  • Share new debugging tricks in the team retro so the whole crew benefits.

Quick Navigation

Related Topics

Video Tutorial

Watch and learn testing & debugging quiz

Pro Tip: After reading through the content above, watch this video to reinforce your understanding and see the concepts in action!