Added missing quote from rewrite_css_and_image_references and added support for single quotes

This commit is contained in:
Erin Staniland 2009-05-08 12:01:46 +01:00 committed by Bryan Helmkamp
parent 78a23abb6e
commit b75ff6221b
3 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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:

View File

@ -10,6 +10,7 @@ describe "save_and_open_page" do
<body>
<h1>Hello world</h1>
<img src="/images/bar.png" />
<img src='/images/foo.png' />
</body>
</html>
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