rails-rspec-testing
Installation
SKILL.md
Rails RSpec Conventions
RSpec is the standard test framework here (not Minitest). These rules exist to keep specs deterministic and meaningful, not just green.
No Time-Based Flakiness
Never rely on real wall-clock time in code under test or in the spec itself. Use ActiveSupport::Testing::TimeHelpers (travel_to, freeze_time) — never sleep, and never assert against a freshly-computed Time.current in the same line the code under test also computes it.
# Wrong — flaky, depends on how fast the test runs
it "expires after 1 hour" do
token = GenerateLoginCode.call
expect(token.expires_at).to eq(Time.current + 1.hour)
end