diff --git a/lib/capybara/util/save_and_open_page.rb b/lib/capybara/util/save_and_open_page.rb index 29f4dfbf7..c817cf9d8 100644 --- a/lib/capybara/util/save_and_open_page.rb +++ b/lib/capybara/util/save_and_open_page.rb @@ -26,11 +26,10 @@ def open_in_browser(path) # :nodoc def rewrite_css_and_image_references(response_html) # :nodoc: return response_html unless Capybara.asset_root - directories = Dir.new(Capybara.asset_root).entries.inject([]) do |list, name| - list << name if File.directory?(name) and not name.to_s =~ /^\./ - list - end - response_html.gsub(/("|')\/(#{directories.join('|')})/, '\1' + Capybara.asset_root.to_s + '/\2') + directories = Dir.new(Capybara.asset_root).entries.select { |name| + File.directory?(name) and not name.to_s =~ /^\./ + } + response_html.gsub(/=("|')\/(#{directories.join('|')})/, '=\1' + Capybara.asset_root.to_s + '/\2') end end end