Sha256: 9cbaa316287f2ae6ebed9ed05fe2bf43af6d854bf30de452719cf4f460d87b25

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require File.dirname(__FILE__) + '/spec_helper.rb'

describe "ClickableElement" do

  before :all do
    @browser = Browser.new(BROWSER_OPTIONS.merge(:log_level => :off))
  end

  before :each do
    @browser.goto(HTML_DIR + "/non_control_elements.html")
  end

  describe "#click_and_attach" do
    it 'opens a page in a new browser with the same options' do
      browser = @browser.link(:name, /bad_attribute/).click_and_attach
      browser.text.include?("User administration").should be_true # to make sure it is open.
      browser.options.should == @browser.options
      browser.cookies.should == @browser.cookies
    end

    it "opens the page in a new browser with the same cookies" do
      @browser.add_cookie("localhost", "foo", "bar")
      old_cookies = @browser.cookies
      old_cookies.should_not be_empty

      @browser.goto(HTML_DIR + "/non_control_elements.html")
      browser = @browser.link(:name, /bad_attribute/).click_and_attach

      browser.should_not == @browser
      browser.cookies.should == old_cookies
    end
  end

  describe "#download" do
    it 'returns a click-opened page as io' do
      expected = File.read "#{HTML_DIR}/forms_with_input_elements.html".sub("file://", '')

      @browser.link(:name, /bad_attribute/).download.read.should == expected
      @browser.link(:name, /bad_attribute/).should exist
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caius-celerity-0.0.6.11 spec/clickable_element_spec.rb