Best practices: Writing a Rails script (and how to test it)

Rails one-off scripts need idempotence, transactions, transparency, and robust error handling; isolating logic from input also makes them testable.

Defining custom RSpec matchers

Custom RSpec matchers support reusable test assertions, chaining, block expectations, and complex matcher classes for domain-specific checks.

Test your application's e-mail spam scoring with mail-tester.com

Check outbound mail for spam filters and deliverability issues with mail-tester.com; a score around 9/10 is usually fine, while plain-text bodies and proper DNS help avoid false positives.

Capybara: Preventing headless Chrome from freezing your test suite

Headless Chrome can freeze feature tests and leave Capybara waiting on a dead browser; restarting the session periodically and using a custom HTTP client surfaces failures sooner.

Before you make a merge request: Checklist for common mistakes

Common merge request mistakes cause rejections; this checklist helps verify acceptance criteria, tests, UI quality, performance, translations, and documentation before submission.

Test-Driven Development with integration and unit tests: a pragmatic approach

Dogmatic red-green-refactor TDD can be tedious; a pragmatic mix of integration and unit tests uses scenario titles as a todo list and supports iterative development.

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.

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.

Split your parallel tests by execution time and keep execution logs up to date

Historic timing data keeps test distribution balanced, but stale logs and CI-only updates can skew results and clutter diffs. Automating runtime log generation reduces maintenance.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Careful when using Time objects for generating ETags

Time values in ETag generation can lose millisecond precision, causing stale cache hits and flaky tests. Convert them to strings or numbers before combining cache keys.

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.