Skip to content

Instantly share code, notes, and snippets.

@tmikoss
Last active December 20, 2015 05:29
Show Gist options
  • Save tmikoss/6079190 to your computer and use it in GitHub Desktop.
Save tmikoss/6079190 to your computer and use it in GitHub Desktop.
RSpec::Matchers.define :finish_within do |timeout|
match do |block|
begin
Timeout.timeout(timeout) do
Benchmark.realtime{ block.call } <= timeout
end
rescue TimeoutError
false
end
end
end
it "should respond in 0.1s" do
expect {
visit '/'
}.to finish_within 0.1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment