1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/spec/timeout_spec.rb

29 lines
677 B
Ruby
Raw Normal View History

require File.expand_path('spec_helper', File.dirname(__FILE__))
require 'capybara'
2010-07-09 21:06:44 -04:00
require 'capybara/util/timeout'
module Capybara
2010-09-15 12:19:50 -04:00
2010-07-09 14:30:50 -04:00
describe '.timeout' do
2010-09-15 12:19:50 -04:00
it "should return result of yield if it returns true value within timeout" do
2010-07-09 14:30:50 -04:00
Capybara.timeout { "hello" }.should == "hello"
end
2010-09-15 12:19:50 -04:00
it "should keep trying within timeout" do
count = 0
2010-07-09 14:30:50 -04:00
Capybara.timeout { count += 1; count == 5 ? count : nil }.should == 5
end
2010-09-15 12:19:50 -04:00
it "should raise Capybara::TimeoutError if block fails to return true within timeout" do
2010-09-15 12:19:50 -04:00
running do
2010-07-09 14:30:50 -04:00
Capybara.timeout(0.1) { false }
end.should raise_error(::Capybara::TimeoutError)
end
2010-09-15 12:19:50 -04:00
end
2010-09-15 12:19:50 -04:00
end
2010-09-15 12:19:50 -04:00