Give the browser time to actually load the page before expecting to be
on it
This commit is contained in:
parent
9d5e1f604d
commit
7e4504edf2
2 changed files with 18 additions and 2 deletions
17
features/support/matchers.rb
Normal file
17
features/support/matchers.rb
Normal 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
|
||||||
|
|
@ -66,8 +66,7 @@ module NavigationHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
def confirm_on_page(page_name)
|
def confirm_on_page(page_name)
|
||||||
current_path = URI.parse(current_url).path
|
expect(page).to have_path(path_to(page_name))
|
||||||
expect(current_path).to eq(path_to(page_name))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue