From 6203484b09072f095cb81198392f0511899663a9 Mon Sep 17 00:00:00 2001 From: Erin Staniland Date: Fri, 8 May 2009 12:01:46 +0100 Subject: [PATCH] Added missing quote from rewrite_css_and_image_references and added support for single quotes --- lib/webrat/core/save_and_open_page.rb | 2 +- spec/public/save_and_open_spec.rb | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/webrat/core/save_and_open_page.rb b/lib/webrat/core/save_and_open_page.rb index 1e49f30..0b4aef6 100644 --- a/lib/webrat/core/save_and_open_page.rb +++ b/lib/webrat/core/save_and_open_page.rb @@ -28,7 +28,7 @@ module Webrat def rewrite_css_and_image_references(response_html) # :nodoc: return response_html unless doc_root - response_html.gsub(/"\/(stylesheets|images)/, doc_root + '/\1') + response_html.gsub(/("|')\/(stylesheets|images)/, '\1' + doc_root + '/\2') end def saved_page_dir #:nodoc: diff --git a/spec/public/save_and_open_spec.rb b/spec/public/save_and_open_spec.rb index f6ab953..150a6e1 100644 --- a/spec/public/save_and_open_spec.rb +++ b/spec/public/save_and_open_spec.rb @@ -10,6 +10,7 @@ describe "save_and_open_page" do

Hello world

+ HTML @@ -25,15 +26,23 @@ describe "save_and_open_page" do it "should rewrite css rules" do @file_handle.should_receive(:write) do |html| - html.should =~ %r|#{webrat_session.doc_root}/stylesheets/foo.css|s + html.should =~ %r|"#{webrat_session.doc_root}/stylesheets/foo.css"|s end save_and_open_page end - it "should rewrite image paths" do + it "should rewrite image paths with double quotes" do @file_handle.should_receive(:write) do |html| - html.should =~ %r|#{webrat_session.doc_root}/images/bar.png|s + html.should =~ %r|"#{webrat_session.doc_root}/images/bar.png"|s + end + + save_and_open_page + end + + it "should rewrite image paths with single quotes" do + @file_handle.should_receive(:write) do |html| + html.should =~ %r|'#{webrat_session.doc_root}/images/foo.png'|s end save_and_open_page -- 1.6.1.1