Give the browser time to actually load the page before expecting to be

on it
This commit is contained in:
Jonne Haß 2014-12-04 18:13:56 +01:00
parent 9d5e1f604d
commit 7e4504edf2
2 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,17 @@
RSpec::Matchers.define :have_path do |expected|
match do |actual|
start_time = Time.now
until actual.current_path == expected
return false if (Time.now-start_time) > Capybara.default_wait_time
sleep 0.05
end
true
end
failure_message_for_should do |actual|
"expected #{actual.inspect} to have path #{expected.inspect} but was #{actual.current_path.inspect}"
end
failure_message_for_should_not do |actual|
"expected #{actual.inspect} to not have path #{expected.inspect} but it had"
end
end

View file

@ -66,8 +66,7 @@ module NavigationHelpers
end
def confirm_on_page(page_name)
current_path = URI.parse(current_url).path
expect(current_path).to eq(path_to(page_name))
expect(page).to have_path(path_to(page_name))
end
end