diff --git a/features/support/matchers.rb b/features/support/matchers.rb new file mode 100644 index 000000000..17ce581e4 --- /dev/null +++ b/features/support/matchers.rb @@ -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 diff --git a/features/support/paths.rb b/features/support/paths.rb index 8ccf11987..d1b923091 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -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