Save and open page spec no longer dumps files

This commit is contained in:
Dennis Rogenius 2009-11-22 18:16:45 +01:00
parent 6f0661cc87
commit ae5c86c382
2 changed files with 8 additions and 4 deletions

View File

@ -4,10 +4,13 @@ module Capybara
def save_and_open_page(html)
name="capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"
FileUtils.touch(name) unless File.exist?(name)
tempfile = File.new(name,'w')
tempfile.write(rewrite_css_and_image_references(html))
tempfile.close
open_in_browser(tempfile.path)
end

View File

@ -8,11 +8,13 @@ describe Capybara::SaveAndOpenPage do
@time = Time.new.strftime("%Y%m%d%H%M%S")
name = "capybara-#{@time}.html"
File.should_receive(:exist?).and_return true
@temp_file = File.new(name,'w')
@temp_file = mock("FILE")
@temp_file.stub!(:write)
@temp_file.stub!(:close)
@temp_file.stub!(:path).and_return(name)
File.should_receive(:exist?).and_return true
File.should_receive(:new).and_return @temp_file
@html = <<-HTML
@ -34,8 +36,7 @@ describe Capybara::SaveAndOpenPage do
end
it "should open the file in the browser" do
path = "#{@temp_file.path}"
Capybara::SaveAndOpenPage.should_receive(:open_in_browser).with(path)
Capybara::SaveAndOpenPage.should_receive(:open_in_browser).with(name)
Capybara::SaveAndOpenPage.save_and_open_page @html
end
end