Last active
December 20, 2015 05:29
-
-
Save tmikoss/6079190 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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