Sha256: 160902d16eb57de11286640c499bee1d3a86f139542bdd16387ab16c94bccdbe

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

Capybara::SpecHelper.spec "#choose" do
  before do
    @session.visit('/form')
  end

  it "should choose a radio button by id" do
    @session.choose("gender_male")
    @session.click_button('awesome')
    extract_results(@session)['gender'].should == 'male'
  end

  it "should choose a radio button by label" do
    @session.choose("Both")
    @session.click_button('awesome')
    extract_results(@session)['gender'].should == 'both'
  end

  it "casts to string" do
    @session.choose("Both")
    @session.click_button(:'awesome')
    extract_results(@session)['gender'].should == 'both'
  end

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

  context "with a disabled radio button" do
    it "should raise an error" do
      expect do
        @session.choose('Disabled Radio')
      end.to raise_error(Capybara::ElementNotFound)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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