For years we copied the patiently helpers into our test suites. they now live in their own gem (
makandra/patiently
Show archive.org snapshot
) where we can test them and distribute changes.
Setup
Bundle the patiently gem:
# Gemfile
gem "patiently"
Replace the vendored boilerplate with a single require:
# spec/support/patiently.rb
require "patiently/rspec" # includes the helpers into feature + system specs
Or include it yourself anywhere: include Patiently::Helpers.
Supported helpers
You already know patiently, which retries a block until it stops raising (or times out). Returns the block's value.
patiently { expect(page).to have_content("Saved!") }
patiently(10) { … } # custom timeout in seconds
We also provide patiently_until, which retries until the block returns truthy. Returns true/false. Real errors still propagate.
patiently_until { user.reload.confirmed? }
Configuration
We added some configuration options:
# spec/support/patiently.rb
Patiently.config.timeout = 5 # seconds before giving up
Patiently.config.retry_intervals = [0.05] # sleep between retries (backoff array; last value repeats)
Patiently.config.min_retries = 1 # always retry at least this often (re-attempts after the first call)
Patiently.config.max_retries = nil # cap on retries; nil = unlimited
Defaults match the old vendored helper, so migrating is a drop-in replacement. A mocked/frozen clock raises Patiently::FrozenInTime instead of looping forever.