Skip to content

Commit

Permalink
Added missing quote from rewrite_css_and_image_references and added s…
Browse files Browse the repository at this point in the history
…upport for single quotes
  • Loading branch information
erino authored and brynary committed Jun 15, 2009
1 parent 78a23ab commit b75ff62
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions History.txt
Expand Up @@ -21,6 +21,10 @@
* Adding fix for fields with labels with special characters (Thomas Jack, Mike Gaffney, Bryan Hemlkamp)
* Deprecated current_page lh50 (Mike Gaffney)

* Bug fixes

* Translate CSS and image paths with single quotes in save_and_open_page (Erin Staniland)

== 0.4.4 / 2009-04-06

* Major enhancements
Expand Down
2 changes: 1 addition & 1 deletion lib/webrat/core/save_and_open_page.rb
Expand Up @@ -28,7 +28,7 @@ def open_in_browser(path) # :nodoc

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:
Expand Down
15 changes: 12 additions & 3 deletions spec/public/save_and_open_spec.rb
Expand Up @@ -10,6 +10,7 @@
<body>
<h1>Hello world</h1>
<img src="/images/bar.png" />
<img src='/images/foo.png' />
</body>
</html>
HTML
Expand All @@ -25,15 +26,23 @@

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
Expand Down

0 comments on commit b75ff62

Please sign in to comment.