Sha256: 4e6da40c320bea0e7f3cdabf608b4ef40dce5c1aec0f151e3911bbe2c5f5bd9d

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

Capybara::SpecHelper.spec '#click_link_or_button' do
  it "should click on a link" do
    @session.visit('/with_html')
    @session.click_link_or_button('labore')
    @session.should have_content('Bar')
  end

  it "should click on a button" do
    @session.visit('/form')
    @session.click_link_or_button('awe123')
    extract_results(@session)['first_name'].should == 'John'
  end

  it "should click on a button with no type attribute" do
    @session.visit('/form')
    @session.click_link_or_button('no_type')
    extract_results(@session)['first_name'].should == 'John'
  end

  it "should be aliased as click_on" do
    @session.visit('/form')
    @session.click_on('awe123')
    extract_results(@session)['first_name'].should == 'John'
  end

  it "should wait for asynchronous load", :requires => [:js] do
    @session.visit('/with_js')
    @session.click_link('Click me')
    @session.click_link_or_button('Has been clicked')
  end

  it "casts to string" do
    @session.visit('/form')
    @session.click_link_or_button(:'awe123')
    extract_results(@session)['first_name'].should == 'John'
  end

  context "with a locator that doesn't exist" do
    it "should raise an error" do
      @session.visit('/with_html')
      msg = "Unable to find link or button \"does not exist\""
      expect do
        @session.click_link_or_button('does not exist')
      end.to raise_error(Capybara::ElementNotFound, msg)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
capybara-2.0.3 lib/capybara/spec/session/click_link_or_button_spec.rb
capybara-2.0.2 lib/capybara/spec/session/click_link_or_button_spec.rb
capybara-2.0.1 lib/capybara/spec/session/click_link_or_button_spec.rb
capybara-2.0.0 lib/capybara/spec/session/click_link_or_button_spec.rb
capybara-2.0.0.beta4 lib/capybara/spec/session/click_link_or_button_spec.rb