Sha256: 7a69613c5317d13b5b2822666b793e16a398b09ef09b24ad6970aca28bd8b1bd

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe "save_and_open_page" do
  before do
    with_html <<-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.stub!(:exist? => true)
    Time.stub!(:now => 1234)
    webrat_session.stub!(:open_in_browser)
    
    @file_handle = mock("file handle")
    File.stub!(:open).with(filename, 'w').and_yield(@file_handle)
    @file_handle.stub!(:write)
  end

  it "should rewrite css rules" do
    @file_handle.should_receive(:write) do |html|
      html.should =~ %r|#{webrat_session.doc_root}/stylesheets/foo.css|s
    end
    
    save_and_open_page
  end
  
  it "should rewrite image paths" do
    @file_handle.should_receive(:write) do |html|
      html.should =~ %r|#{webrat_session.doc_root}/images/bar.png|s
    end
    
    save_and_open_page
  end
  
  it "should open the temp file in a browser" do
    webrat_session.should_receive(:open_in_browser).with(filename)
    save_and_open_page
  end
  
  def filename
    File.expand_path("./webrat-#{Time.now}.html")
  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 test/webrat/spec/public/save_and_open_spec.rb
adva-0.3.1 test/webrat/spec/public/save_and_open_spec.rb
adva-0.3.0 test/webrat/spec/public/save_and_open_spec.rb
adva-0.2.4 test/webrat/spec/public/save_and_open_spec.rb
adva-0.2.3 test/webrat/spec/public/save_and_open_spec.rb
adva-0.2.2 test/webrat/spec/public/save_and_open_spec.rb
adva-0.2.1 test/webrat/spec/public/save_and_open_spec.rb
adva-0.2.0 test/webrat/spec/public/save_and_open_spec.rb
adva-0.1.4 test/webrat/spec/public/save_and_open_spec.rb
adva-0.1.3 test/webrat/spec/public/save_and_open_spec.rb
adva-0.1.2 test/webrat/spec/public/save_and_open_spec.rb
adva-0.1.1 test/webrat/spec/public/save_and_open_spec.rb
adva-0.1.0 test/webrat/spec/public/save_and_open_spec.rb
adva-0.0.1 test/webrat/spec/public/save_and_open_spec.rb
integrity-0.1.9 vendor/webrat/spec/public/save_and_open_spec.rb