test and fix for issue #1444

This commit is contained in:
Thomas Walpole 2015-04-14 12:46:00 -07:00
parent bab9032ee4
commit 80bdab5bf7
4 changed files with 12 additions and 2 deletions

View File

@ -27,7 +27,7 @@ class Capybara::RackTest::Browser
end
def follow(method, path, attributes = {})
return if path.gsub(/^#{request_path}/, '').start_with?('#') || path.downcase.start_with?('javascript:')
return if path.gsub(/^#{Regexp.escape(request_path)}/, '').start_with?('#') || path.downcase.start_with?('javascript:')
process_and_follow_redirects(method, path, attributes, {'HTTP_REFERER' => current_url})
end

View File

@ -131,6 +131,12 @@ Capybara::SpecHelper.spec '#click_link' do
expect(@session).to have_content('Bar')
end
it "should follow link on anchor if the path has regex special characters" do
@session.visit('/with.*html')
@session.click_link('Anchor on different page')
expect(@session).to have_content('Bar')
end
it "raise an error with links with no href" do
expect do
@session.click_link('No Href')

View File

@ -119,7 +119,7 @@ Capybara::SpecHelper.spec Capybara::Window, requires: [:windows] do
end
end
describe '#maximize', tw: true do
describe '#maximize' do
it 'should be able to maximize window', requires: [:windows, :js] do
skip "This test fails when run with Firefox on Travis - see issue #1493 - skipping for now" if ENV['TRAVIS'] && @session.respond_to?(:mode) && (@session.mode == :selenium_focus)
screen_width, screen_height = @session.evaluate_script("[window.screen.availWidth, window.screen.availHeight];")

View File

@ -127,6 +127,10 @@ class TestApp < Sinatra::Base
raise LoadError
end
get '/with.*html' do
erb :with_html
end
get '/:view' do |view|
erb view.to_sym
end