1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Add tests for current_path matcher

This commit is contained in:
Thomas Walpole 2017-10-04 17:54:04 -07:00
parent fc0d4c412a
commit 00938f51cb

View file

@ -37,8 +37,24 @@ Capybara::SpecHelper.spec '#has_current_path?' do
expect(@session).to have_current_path('/with_js?test=test') expect(@session).to have_current_path('/with_js?test=test')
end end
it "should compare the full url" do it "should compare the full url if url: true is used" do
expect(@session).to have_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true) expect(@session).to have_current_path(%r{\Ahttp://[^/]*/with_js\Z}, url: true)
domain_port = if @session.respond_to?(:server) && @session.server
"#{@session.server.host}:#{@session.server.port}"
else
"www.example.com"
end
expect(@session).to have_current_path("http://#{domain_port}/with_js", url: true)
end
it "should not compare the full url if url: true is not passed" do
expect(@session).to have_current_path(%r{^/with_js\Z})
expect(@session).to have_current_path('/with_js')
end
it "should not compare the full url if url: false is passed" do
expect(@session).to have_current_path(%r{^/with_js\Z}, url: false)
expect(@session).to have_current_path('/with_js', url: false)
end end
it "should ignore the query" do it "should ignore the query" do