Ruby Testing
RSpec Getting Started: Installation, Structure, and Core Syntax
RSpec is the dominant testing framework in the Ruby ecosystem. It's been around since 2005 and has shaped how Ruby developers think about tests.
Ruby Testing
RSpec is the dominant testing framework in the Ruby ecosystem. It's been around since 2005 and has shaped how Ruby developers think about tests.
Ruby Testing
Testing a Rails application with RSpec involves more than just the base rspec gem. You need rspec-rails for Rails-specific example groups, factory_bot_rails for test data, capybara for browser interaction, and database_cleaner-active_record to keep your database clean between tests. This post covers how to
Ruby Testing
Test duplication is a real problem. When you have ten model specs that each test the same #timestamps behavior, or five controller specs that each verify authentication, copy-paste is the wrong answer. RSpec gives you two tools for this: shared examples and shared contexts. Shared examples let you define
Ruby
When multiple objects share the same interface or behaviour, copy-pasting test cases is a maintenance trap. RSpec's shared examples and shared contexts let you write that behaviour once and include it wherever it applies. Shared Examples Defining shared examples # spec/support/shared_examples/paginatable.rb RSpec.shared_
Ruby
Test doubles let you isolate the unit under test by replacing collaborators with controlled stand-ins. RSpec ships with a full mocking library — no extra gems needed. This guide covers everything from basic stubs to strict message expectations. The Four Types of Test Doubles Type Purpose Double Pure stand-in
Ruby Testing
Mocking and stubbing are how you isolate the thing you're testing from everything it depends on. Without them, a unit test that touches a database, an external API, or a slow service stops being a unit test — it becomes an integration test wearing a unit test costume. RSpec
Ruby Testing
Good RSpec tests are fast, readable, and fail for the right reasons. Bad ones are slow, coupled to implementation, full of mocks, and when they fail you can't tell what's broken. This post covers the conventions and patterns that separate maintainable RSpec suites from the ones
Ruby
Rails APIs need a different testing approach than HTML applications. There's no browser to drive, no UI interactions — just HTTP requests and JSON responses.