RSpec: Where to put custom matchers and other support code

Custom RSpec matchers and support code need a clear home in spec/support to keep specs DRY and make shared helpers available everywhere.

Upgrade guide for moving a Rails app from Webpack 3 to Webpack 4

Webpacker 4 and Babel 7 change config files, package names, asset paths, and polyfill imports when upgrading a Rails app from Webpack 3.

Migration from the Asset Pipeline to Webpacker

Moving a Rails app from the Asset Pipeline to Webpacker requires inventorying bundled libraries, repackaging legacy assets, and adjusting deployment for pack-based assets.

How to access before/after pseudo element styles with JavaScript

Pseudo-element styles are hard to inspect directly, but getComputedStyle can read ::before and ::after values for testing and color checks.

Controller specs do not persist the Rails session across requests of the same spec

Controller specs reset the Rails session on every request, so data written earlier disappears between calls. Stubbing controller.session with a shared TestSession preserves state for testing.

PostgreSQL's OVERLAPS operator is not fully inclusive

PostgreSQL OVERLAPS treats date ranges as start <= time < end, so boundary dates are excluded and adjacent ranges do not match.

RawGit

Serve raw GitHub files with correct Content-Type headers for CDN-style testing or prototyping, but without any uptime guarantee.

How to create Excel sheets with spreadsheet gem and use number formats for cells like money or date

Create .xls files with the spreadsheet gem and apply number formats for currency and dates, including cell links.

RSpec: Where to put shared example groups

Shared example groups need a clear home in RSpec, since the default rspec-rails layout does not provide one. Organizing them in dedicated shared_examples folders keeps them reusable and easy to load.

Working around OpenSSL::SSL::SSLErrors

Ruby and curl requests can fail when a server only accepts older SSL/TLS versions; forcing a specific protocol version can restore connectivity.

How to upgrade Cucumber on Rails 3+

Updating Cucumber on Rails 3+ requires refreshing cucumber, capybara, and cucumber-rails, then restoring any custom support setup after installation.

Spreewald 1.2.0 released: new "select field should be sorted" step

Bugs in select-field ordering can make form choices appear in the wrong sequence; a sorting check helps verify ordered and unordered dropdowns behave correctly.

VCR: An OAuth-compatible request matcher

OAuth query parameters with nonces or timestamps make VCR request matching fail because each URI changes. A custom matcher can ignore the variable OAuth values.

Cucumber: How to find unused step definitions

Cucumber can list step definitions separately, helping detect dead or duplicate steps before cleanup. --dry-run and --format stepdefs reveal candidates, but nested step calls can look unused.

Chaining Capybara matchers in RSpec

Chaining Capybara matchers with and retries the full expectation when one check fails, making multiple assertions more reliable on pages that change asynchronously.

Better output for Cucumber

cucumber_spinner adds a progress bar for Cucumber features and shows failing scenarios immediately, with optional browser opening for failed pages.

Upgrading a Rails app to Cucumber 3

Rails apps upgrading to Cucumber 3 often need gem updates, new tag syntax, and step-definition fixes to avoid parser and argument-mismatch errors.

How to avoid ActiveRecord::EnvironmentMismatchError on "rails db:drop"

Rails database tasks can fail with ActiveRecord::EnvironmentMismatchError after restoring a dump from another environment. Updating ar_internal_metadata or disabling the environment check lets rails db:drop proceed.

Mixed Content Examples

Mixed content behavior differs when secure pages load assets over HTTPS versus HTTP, exposing browser handling of blocked or downgraded resources.

Browsers will not send a referrer when linking from HTTPS to HTTP

Secure pages linking to insecure destinations suppress the Referer header, making visits appear as direct traffic and breaking source tracking.

Chrome Lighthouse

Built-in Chrome auditing checks performance, accessibility, and other quality signals for web apps, including private or local pages. Development settings can skew results; Webpagetest is an alternative.

Action Mailer Previews

Previewing Rails emails in the browser catches layout and content issues before delivery and helps keep mailer output aligned with expectations.

Ollama: Strip image data from VCR recorded requests

VCR cassettes can bloat with base64-encoded vision payloads and leaked Basic Auth credentials; sanitizing request bodies and custom matching keep recordings small and playback reliable.

Rspec: around(:all) and around(:each) hook execution order

RSpec hook order matters when around(:all) and around(:each) wrap setup and teardown; their execution timing differs from before and after hooks.