more travis test timing allowance

This commit is contained in:
Thomas Walpole 2017-05-10 12:27:53 -07:00
parent 13001e21bc
commit 827c22b5fb
10 changed files with 42 additions and 28 deletions

View File

@ -63,7 +63,7 @@ Capybara::SpecHelper.spec '#accept_alert', requires: [:modals] do
end end
it "should allow to adjust the delay" do it "should allow to adjust the delay" do
@session.accept_alert wait: 4 do @session.accept_alert wait: 10 do
@session.click_link('Open slow alert') @session.click_link('Open slow alert')
end end
expect(@session).to have_xpath("//a[@id='open-slow-alert' and @opened='true']") expect(@session).to have_xpath("//a[@id='open-slow-alert' and @opened='true']")

View File

@ -65,7 +65,7 @@ Capybara::SpecHelper.spec '#assert_selector' do
Capybara.using_wait_time(0.1) do Capybara.using_wait_time(0.1) do
@session.visit('/with_js') @session.visit('/with_js')
@session.click_link('Click me') @session.click_link('Click me')
@session.assert_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 0.9) @session.assert_selector(:css, "a#has-been-clicked", text: "Has been clicked", wait: 2)
end end
end end
end end

View File

@ -110,14 +110,18 @@ Capybara::SpecHelper.spec '#first' do
it "should wait for at least one match if true" do it "should wait for at least one match if true" do
Capybara.wait_on_first_by_default = true Capybara.wait_on_first_by_default = true
Capybara.using_wait_time(3) do
@session.click_link('clickable') @session.click_link('clickable')
expect(@session.first(:css, 'a#has-been-clicked')).not_to be_nil expect(@session.first(:css, 'a#has-been-clicked')).not_to be_nil
end end
end
it "should return nil after waiting if no match" do it "should return nil after waiting if no match" do
Capybara.wait_on_first_by_default = true Capybara.wait_on_first_by_default = true
Capybara.using_wait_time(3) do
@session.click_link('clickable') @session.click_link('clickable')
expect(@session.first(:css, 'a#not-a-real-link')).to be_nil expect(@session.first(:css, 'a#not-a-real-link')).to be_nil
end end
end end
end
end end

View File

@ -83,9 +83,11 @@ Capybara::SpecHelper.spec '#has_no_current_path?' do
end end
it "should wait for current_path to disappear", requires: [:js] do it "should wait for current_path to disappear", requires: [:js] do
Capybara.using_wait_time(3) do
@session.click_link("Change page") @session.click_link("Change page")
expect(@session).to have_no_current_path('/with_js') expect(@session).to have_no_current_path('/with_js')
end end
end
it "should be true if the page has not the given current_path" do it "should be true if the page has not the given current_path" do
expect(@session).to have_no_current_path('/with_html') expect(@session).to have_no_current_path('/with_html')

View File

@ -125,10 +125,12 @@ Capybara::SpecHelper.spec '#has_text?' do
end end
it "should wait for text to appear", requires: [:js] do it "should wait for text to appear", requires: [:js] do
Capybara.using_wait_time(3) do
@session.visit('/with_js') @session.visit('/with_js')
@session.click_link('Click me') @session.click_link('Click me')
expect(@session).to have_text("Has been clicked") expect(@session).to have_text("Has been clicked")
end end
end
context "with between" do context "with between" do
it "should be true if the text occurs within the range given" do it "should be true if the text occurs within the range given" do

View File

@ -53,9 +53,11 @@ Capybara::SpecHelper.spec '#has_no_title?' do
end end
it "should wait for title to disappear", requires: [:js] do it "should wait for title to disappear", requires: [:js] do
@session.click_link("Change title") Capybara.using_wait_time(5) do
@session.click_link("Change title") # triggers title change after 400ms
expect(@session).to have_no_title('with_js') expect(@session).to have_no_title('with_js')
end end
end
it "should be true if the page has not the given title" do it "should be true if the page has not the given title" do
expect(@session).to have_no_title('monkey') expect(@session).to have_no_title('monkey')

View File

@ -29,10 +29,12 @@ Capybara::SpecHelper.spec '#has_xpath?' do
end end
it "should wait for content to appear", requires: [:js] do it "should wait for content to appear", requires: [:js] do
Capybara.using_wait_time(3) do
@session.visit('/with_js') @session.visit('/with_js')
@session.click_link('Click me') @session.click_link('Click me') # updates page after 500ms
expect(@session).to have_xpath("//input[@type='submit' and @value='New Here']") expect(@session).to have_xpath("//input[@type='submit' and @value='New Here']")
end end
end
context "with count" do context "with count" do
it "should be true if the content occurs the given number of times" do it "should be true if the content occurs the given number of times" do

View File

@ -471,6 +471,7 @@ Capybara::SpecHelper.spec "node" do
end end
it "should reload nodes with options" do it "should reload nodes with options" do
Capybara.using_wait_time(4) do
@session.visit('/with_js') @session.visit('/with_js')
node = @session.find(:css, 'em', text: "reloaded") node = @session.find(:css, 'em', text: "reloaded")
@session.click_link('Reload!') @session.click_link('Reload!')
@ -479,6 +480,7 @@ Capybara::SpecHelper.spec "node" do
end end
end end
end end
end
context "when #synchronize raises server errors" do context "when #synchronize raises server errors" do
it "sets an explanatory exception as the cause of server exceptions", requires: [:server, :js] do it "sets an explanatory exception as the cause of server exceptions", requires: [:server, :js] do

View File

@ -21,7 +21,7 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.execute_script('setTimeout(function(){ window.close(); }, 500);') @session.execute_script('setTimeout(function(){ window.close(); }, 500);')
end end
Capybara.using_wait_time 0.1 do Capybara.using_wait_time 0.1 do
expect(@other_window).to become_closed(wait: 2) expect(@other_window).to become_closed(wait: 5)
end end
end end
@ -42,7 +42,7 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.within_window @other_window do @session.within_window @other_window do
@session.execute_script('setTimeout(function(){ window.close(); }, 500);') @session.execute_script('setTimeout(function(){ window.close(); }, 500);')
end end
Capybara.using_wait_time 1.5 do Capybara.using_wait_time 5 do
expect(@other_window).to become_closed expect(@other_window).to become_closed
end end
end end
@ -75,10 +75,10 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.within_window @other_window do @session.within_window @other_window do
@session.execute_script('setTimeout(function(){ window.close(); }, 700);') @session.execute_script('setTimeout(function(){ window.close(); }, 700);')
end end
Capybara.using_wait_time 1.1 do Capybara.using_wait_time 3.1 do
expect do expect do
expect(@other_window).not_to become_closed expect(@other_window).not_to become_closed
end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /\Aexpected #<Window @handle=".+"> not to become closed after 1.1 seconds\Z/) end.to raise_error(RSpec::Expectations::ExpectationNotMetError, /\Aexpected #<Window @handle=".+"> not to become closed after 3.1 seconds\Z/)
end end
end end
end end

View File

@ -22,12 +22,12 @@ Capybara::SpecHelper.spec '#window_opened_by', requires: [:windows] do
Capybara.using_wait_time 2 do Capybara.using_wait_time 2 do
button=@session.find(:css, '#openWindowWithLongerTimeout') button=@session.find(:css, '#openWindowWithLongerTimeout')
expect do expect do
@session.window_opened_by(wait: 0.8) do @session.window_opened_by(wait: 0.3) do
button.click button.click
end end
end.to raise_error(Capybara::WindowError, zero_windows_message) end.to raise_error(Capybara::WindowError, zero_windows_message)
end end
@session.document.synchronize(2, errors: [Capybara::CapybaraError]) do @session.document.synchronize(5, errors: [Capybara::CapybaraError]) do
raise Capybara::CapybaraError if @session.windows.size != 2 raise Capybara::CapybaraError if @session.windows.size != 2
end end
end end
@ -60,7 +60,7 @@ Capybara::SpecHelper.spec '#window_opened_by', requires: [:windows] do
it 'should find window if default_max_wait_time is more than timeout' do it 'should find window if default_max_wait_time is more than timeout' do
button = @session.find(:css, '#openWindowWithTimeout') button = @session.find(:css, '#openWindowWithTimeout')
Capybara.using_wait_time 1.5 do Capybara.using_wait_time 5 do
window = @session.window_opened_by do window = @session.window_opened_by do
button.click button.click
end end