Sha256: 7f8dafa384818552fef901acd426435785883b33b20c07df54dac643f2ccf008

Contents?: true

Size: 1.9 KB

Versions: 6

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

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

  it "should be true if the given button is on the page" do
    expect(@session).to have_button('med')
    expect(@session).to have_button('crap321')
    expect(@session).to have_button(:crap321)
  end

  it "should be true for disabled buttons if disabled: true" do
    expect(@session).to have_button('Disabled button', disabled: true)
  end

  it "should be false if the given button is not on the page" do
    expect(@session).not_to have_button('monkey')
  end

  it "should be false for disabled buttons by default" do
    expect(@session).not_to have_button('Disabled button')
  end

  it "should be false for disabled buttons if disabled: false" do
    expect(@session).not_to have_button('Disabled button', disabled: false)
  end

  it "should be true for disabled buttons if disabled: :all" do
    expect(@session).to have_button('Disabled button', disabled: :all)
  end

  it "should be true for enabled buttons if disabled: :all" do
    expect(@session).to have_button('med', disabled: :all)
  end
end

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

  it "should be true if the given button is on the page" do
    expect(@session).not_to have_no_button('med')
    expect(@session).not_to have_no_button('crap321')
  end

  it "should be true for disabled buttons if disabled: true" do
    expect(@session).not_to have_no_button('Disabled button', disabled: true)
  end

  it "should be false if the given button is not on the page" do
    expect(@session).to have_no_button('monkey')
  end

  it "should be false for disabled buttons by default" do
    expect(@session).to have_no_button('Disabled button')
  end

  it "should be false for disabled buttons if disabled: false" do
    expect(@session).to have_no_button('Disabled button', disabled: false)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capybara-3.0.3 lib/capybara/spec/session/has_button_spec.rb
capybara-3.0.2 lib/capybara/spec/session/has_button_spec.rb
capybara-3.0.1 lib/capybara/spec/session/has_button_spec.rb
capybara-3.0.0 lib/capybara/spec/session/has_button_spec.rb
capybara-3.0.0.rc2 lib/capybara/spec/session/has_button_spec.rb
capybara-3.0.0.rc1 lib/capybara/spec/session/has_button_spec.rb