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
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')
end
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
@session.visit('/with_js')
@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

View File

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

View File

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

View File

@ -125,9 +125,11 @@ Capybara::SpecHelper.spec '#has_text?' do
end
it "should wait for text to appear", requires: [:js] do
@session.visit('/with_js')
@session.click_link('Click me')
expect(@session).to have_text("Has been clicked")
Capybara.using_wait_time(3) do
@session.visit('/with_js')
@session.click_link('Click me')
expect(@session).to have_text("Has been clicked")
end
end
context "with between" do

View File

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

View File

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

View File

@ -471,11 +471,13 @@ Capybara::SpecHelper.spec "node" do
end
it "should reload nodes with options" do
@session.visit('/with_js')
node = @session.find(:css, 'em', text: "reloaded")
@session.click_link('Reload!')
sleep(1)
expect(node.text).to eq('has been reloaded')
Capybara.using_wait_time(4) do
@session.visit('/with_js')
node = @session.find(:css, 'em', text: "reloaded")
@session.click_link('Reload!')
sleep(1)
expect(node.text).to eq('has been reloaded')
end
end
end
end

View File

@ -21,7 +21,7 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.execute_script('setTimeout(function(){ window.close(); }, 500);')
end
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
@ -42,7 +42,7 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.within_window @other_window do
@session.execute_script('setTimeout(function(){ window.close(); }, 500);')
end
Capybara.using_wait_time 1.5 do
Capybara.using_wait_time 5 do
expect(@other_window).to become_closed
end
end
@ -75,10 +75,10 @@ Capybara::SpecHelper.spec '#become_closed', requires: [:windows, :js] do
@session.within_window @other_window do
@session.execute_script('setTimeout(function(){ window.close(); }, 700);')
end
Capybara.using_wait_time 1.1 do
Capybara.using_wait_time 3.1 do
expect do
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

View File

@ -22,12 +22,12 @@ Capybara::SpecHelper.spec '#window_opened_by', requires: [:windows] do
Capybara.using_wait_time 2 do
button=@session.find(:css, '#openWindowWithLongerTimeout')
expect do
@session.window_opened_by(wait: 0.8) do
@session.window_opened_by(wait: 0.3) do
button.click
end
end.to raise_error(Capybara::WindowError, zero_windows_message)
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
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
button = @session.find(:css, '#openWindowWithTimeout')
Capybara.using_wait_time 1.5 do
Capybara.using_wait_time 5 do
window = @session.window_opened_by do
button.click
end