Sha256: a93b7fd8c914ea1511bab7a6ed43246cc85180e0a43dcfe33869414a54b57111

Contents?: true

Size: 1.24 KB

Versions: 14

Compression:

Stored size: 1.24 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" />
          <img src='/images/foo.png' />
        </body>
      </html>
    HTML

    File.stub!(:exist? => true)
    Time.stub!(:now => 1234)

    require "launchy"
    Launchy::Browser.stub!(:run)

    @file_handle = mock("file handle")
    File.stub!(:open).and_yield(@file_handle)
    @file_handle.stub!(:write)
  end

  it "should save pages to the directory configured" do
    Webrat.configuration.stub!(:saved_pages_dir => "path/to/dir")
    File.should_receive(:open).with("path/to/dir/webrat-1234.html", "w").and_yield(@file_handle)

    save_and_open_page
  end

  it "should open the temp file in a browser with Launchy" do
    Launchy::Browser.should_receive(:run)
    save_and_open_page
  end

  it "should fail gracefully if Launchy is not available" do
    Launchy::Browser.should_receive(:run).and_raise(LoadError)

    lambda do
      save_and_open_page
    end.should_not raise_error
  end

end

Version data entries

14 entries across 14 versions & 7 rubygems

Version Path
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/spec/public/save_and_open_spec.rb
webrat-0.7.3 spec/public/save_and_open_spec.rb
jbd-webrat-0.7.2.rails3 spec/public/save_and_open_spec.rb
webrat-0.7.2 spec/public/save_and_open_spec.rb
webrat-0.7.2.beta.2 spec/public/save_and_open_spec.rb
mutle-webrat-0.7.2.beta.1 spec/public/save_and_open_spec.rb
thoughtbot-webrat-0.7.2.pre spec/public/save_and_open_spec.rb
webrat-0.7.2.beta.1 spec/public/save_and_open_spec.rb
revo-webrat-0.7.0.1 spec/public/save_and_open_spec.rb
webrat-0.7.1 spec/public/save_and_open_spec.rb
davidtrogers-webrat-0.7.0 spec/public/save_and_open_spec.rb
revo-webrat-0.7.0 spec/public/save_and_open_spec.rb
revo-webrat-0.7.1.pre spec/public/save_and_open_spec.rb
webrat-0.7.0 spec/public/save_and_open_spec.rb