Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save_and_open_page rewrites css and image references to provide a fri…
…endlier debugging experience
- Loading branch information
Showing
5 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/spec_helper") | ||
|
||
RAILS_ROOT = "." unless defined?(RAILS_ROOT) | ||
|
||
describe "save_and_open_page" do | ||
before do | ||
@session = ActionController::Integration::Session.new | ||
@response = mock | ||
@session.stubs(:response).returns(@response) | ||
@response.stubs(:body).returns(<<-HTML | ||
<html><head> | ||
<link href="/stylesheets/foo.css" media="screen" rel="stylesheet" type="text/css" /> | ||
</head><body> | ||
<h1>Hello world</h1> | ||
<img src="/images/bar.png" /> | ||
</body></html> | ||
HTML | ||
) | ||
File.stubs(:exist?).returns(true) | ||
Time.stubs(:now).returns(1234) | ||
end | ||
|
||
it "should rewrite css rules" do | ||
file_handle = mock() | ||
File.expects(:open).with(RAILS_ROOT + "/tmp/webrat-1234.html", 'w').yields(file_handle) | ||
file_handle.expects(:write).with{|html| html =~ %r|#{RAILS_ROOT}/public/stylesheets/foo.css|s } | ||
Webrat::Page.any_instance.stubs(:open_in_browser) | ||
@session.save_and_open_page | ||
end | ||
|
||
it "should rewrite image paths" do | ||
file_handle = mock() | ||
File.expects(:open).with(RAILS_ROOT + "/tmp/webrat-1234.html", 'w').yields(file_handle) | ||
file_handle.expects(:write).with{|html| html =~ %r|#{RAILS_ROOT}/public/images/bar.png|s } | ||
Webrat::Page.any_instance.stubs(:open_in_browser) | ||
@session.save_and_open_page | ||
end | ||
|
||
it "should open the temp file in a browser" do | ||
File.stubs(:open) | ||
Webrat::Page.any_instance.expects(:open_in_browser).with(RAILS_ROOT + "/tmp/webrat-1234.html") | ||
@session.save_and_open_page | ||
end | ||
|
||
end |
Is there any way to turn this off? It is so bloody annoying because when running `rake spec:rcov` Safari opens about 15 blank webrat files that are all empty and completely destroys the ability to keep working while rcov is running in the background.