The Self-Contained Test
Shared test setup makes example files harder to read and change; self-contained examples keep tests clearer and easier to extend.
Faking and testing the network with WebMock
Network-dependent tests can avoid real HTTP by stubbing remote responses and asserting requests with WebMock, including query strings and bodies for GET and POST.
How to tackle complex refactorings in big projects
Large refactorings risk breaking tests, blocking releases, and entangling unrelated changes; breaking work into small green steps keeps long-running project changes manageable.
How to configure Selenium WebDriver to not automatically close alerts or other browser dialogs
Selenium WebDriver dismisses browser dialogs by default and can close alerts before tests react. Setting unhandled_prompt_behavior to ignore leaves prompts open until handled.
Defining custom RSpec matchers
Custom RSpec matchers support reusable test assertions, chaining, block expectations, and complex matcher classes for domain-specific checks.
open-next-failure: An alias to speed up test debugging
Open the next failing spec directly in the IDE to cut down the back-and-forth between test runs and debugging. RSpec --next-failure and JSON output support the workflow.
Capybara: Accessing the parent of an element
Capybara can move from a selected node to its parent with find(:xpath, '..'), useful for checking surrounding links or containers in tests.
Too many parallel test processes may amplify flaky tests
Flaky test suites can fail more often with too many parallel workers; limiting PARALLEL_TEST_PROCESSORS can reduce race-condition failures with only a small runtime cost.
Don't build randomness into your factories
Random values in factories make tests flaky and hide failures; fixed defaults and sequences keep test data predictable.
JavaScript: Testing the type of a value
JavaScript value checks are inconsistent across primitives, objects, arrays, null, undefined, and NaN; the right test depends on whether you need type, instance, or property presence.
Debug flaky tests with an Unpoly observeDelay
Flaky integration tests can outrun watchInputDelay, causing Unpoly field updates to overwrite typed input before requests start. Lowering the delay or signaling CapybaraLockstep reduces failures.
Custom error pages in Rails
Custom Rails error pages can be rendered through controllers instead of static public files, allowing layouts, helpers, and tests for 404 and 500 responses.
How the Date Header Affects Cookie Expiration and Caching
Cookie expiry and HTTP cache lifetimes depend on the Date header when present; missing it can make mocked-time tests and browser caching behave inconsistently.
Taking screenshots in Capybara
Capybara test failures can save screenshots and HTML automatically, with manual capture also available through save_and_open_page, save_screenshot, or Rails ScreenshotHelper.
Lightning Talk: Coverage based Test Case Prioritization in Ruby on Rails
CLI test case prioritization for Ruby on Rails using coverage data can surface failing specs earlier and reduce regression testing time.
How to: Rails cache for individual rspec tests
Rails caching can be enabled for a single RSpec example without changing global test settings. File and memory stores let cache behavior be verified in isolated tests, including parallel runs.
Custom error messages in RSpec or Cucumber steps
RSpec and Cucumber expectations can emit clearer failure messages, making test failures easier to diagnose when matching conditions or subsets of data do not behave as expected.
Stabilize integrations tests with flakiness introduced by Turbo / Stimulus / Hotwire
Turbo-driven Rails integration tests can become flaky under load because asynchronous renders and requests finish unpredictably. A Stimulus-based lockstep controller coordinates Capybara with Turbo events.
How to use Parallel to speed up building the same html partial multiple times (for different data)
Parallel rendering can speed up repeated partials for long lists, but database connections must be cleaned up and transaction-based test setup may break.
Verifying doubles in RSpec 3
Safer test doubles in RSpec 3 verify stubbed methods and argument counts, catching interface mismatches while keeping isolated specs fast.
How to: Use git bisect to find bugs and regressions
Binary search through commits isolates the first bad revision that introduced a bug or regression, with git bisect and optional automated tests.
Heads up: network requests `Kernel#open` are not mocked with VCR
Kernel#open and OpenURI#open_uri can still trigger real network requests in tests because VCR and WebMock do not mock them.
Detect the current Rails environment from JavaScript or CSS
Expose Rails.env on <html> to branch JavaScript and CSS by environment, making Selenium- and test-specific behavior easy to toggle.
Capybara: Working with invisible elements
Capybara hides non-rendered nodes by default, so hidden UI elements need explicit visibility options to be found or asserted in tests.