mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
For Capybara's own test suite, keep default_wait_time always at 1
Until now, we had it set at 0 for all tests that did't require `:js`. But that would cause flickering failures when tests that didn't require `:js` ran against Selenium, e.g. like this: visit '/foo' # asynchronous in Selenium page.should have_content 'Foo' # can fail if visit didn't finish in time This change doubles(!) test suite run time, presumably because we are testing for expected failures in a lot of places, causing us to retry for the full default_wait_time period. At this point though I'm not sure if there's a simple way to avoid the performance hit.
This commit is contained in:
parent
8d50e220c4
commit
0b28aa2e97
3 changed files with 11 additions and 16 deletions
|
@ -12,15 +12,6 @@ module Capybara
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
config.filter_run_excluding :requires => filter
|
config.filter_run_excluding :requires => filter
|
||||||
config.around do |block|
|
|
||||||
if example.metadata[:requires] and example.metadata[:requires].include?(:js)
|
|
||||||
Capybara.default_wait_time = 1
|
|
||||||
block.run
|
|
||||||
Capybara.default_wait_time = 0
|
|
||||||
else
|
|
||||||
block.run
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec(name, options={}, &block)
|
def spec(name, options={}, &block)
|
||||||
|
|
|
@ -110,13 +110,21 @@ describe Capybara::DSL do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#using_wait_time' do
|
describe '#using_wait_time' do
|
||||||
|
before do
|
||||||
|
@previous_wait_time = Capybara.default_wait_time
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Capybara.default_wait_time = @previous_wait_time
|
||||||
|
end
|
||||||
|
|
||||||
it "should switch the wait time and switch it back" do
|
it "should switch the wait time and switch it back" do
|
||||||
in_block = nil
|
in_block = nil
|
||||||
Capybara.using_wait_time 6 do
|
Capybara.using_wait_time 6 do
|
||||||
in_block = Capybara.default_wait_time
|
in_block = Capybara.default_wait_time
|
||||||
end
|
end
|
||||||
in_block.should == 6
|
in_block.should == 6
|
||||||
Capybara.default_wait_time.should == 0
|
Capybara.default_wait_time.should == @previous_wait_time
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should ensure wait time is reset" do
|
it "should ensure wait time is reset" do
|
||||||
|
@ -125,11 +133,7 @@ describe Capybara::DSL do
|
||||||
raise "hell"
|
raise "hell"
|
||||||
end
|
end
|
||||||
end.to raise_error
|
end.to raise_error
|
||||||
Capybara.default_wait_time.should == 0
|
Capybara.default_wait_time.should == @previous_wait_time
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
Capybara.default_wait_time = 0
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ require 'capybara/spec/session'
|
||||||
alias :running :lambda
|
alias :running :lambda
|
||||||
|
|
||||||
Capybara.app = TestApp
|
Capybara.app = TestApp
|
||||||
Capybara.default_wait_time = 0 # less timeout so tests run faster
|
Capybara.default_wait_time = 1 # less timeout so tests run faster
|
||||||
|
|
||||||
module TestSessions
|
module TestSessions
|
||||||
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
||||||
|
|
Loading…
Reference in a new issue