← Graph

You Can Actually Test Rails.env Branches

takeaway 1 connections

From the Rails.env stubbing lightning talk. Code paths gated on Rails.env.development? / Rails.env.production? are not untestable. In minitest, the stub_any_instance gem with a stub_environment helper can make the Rails.env predicates return the desired triple of booleans inside a block. In RSpec, the same is achievable with RSpec mocks and around-example hooks, at the cost of measurably slower tests (test-environment optimizations seem to be bypassed when Rails.env predicates are stubbed).

type
recommendation
takeaway You Can Actually Test Rails.env Branches
from_talk
Main technical takeaway

Provenance

Created in
wroclove.rb 2026 Lightning Talks 2026-04-22 08:41