Merge pull request #1139 from carols10cents/has_button_options

Allows passing options through has_button? to has_selector?
This commit is contained in:
Jonas Nicklas 2013-08-08 17:04:27 -07:00
commit 1273f519d5
3 changed files with 30 additions and 6 deletions

View File

@ -280,8 +280,8 @@ module Capybara
# @param [String] locator The text, value or id of a button to check for
# @return [Boolean] Whether it exists
#
def has_button?(locator)
has_selector?(:button, locator)
def has_button?(locator, options={})
has_selector?(:button, locator, options)
end
##
@ -292,8 +292,8 @@ module Capybara
# @param [String] locator The text, value or id of a button to check for
# @return [Boolean] Whether it doesn't exist
#
def has_no_button?(locator)
has_no_selector?(:button, locator)
def has_no_button?(locator, options={})
has_no_selector?(:button, locator, options)
end
##

View File

@ -126,8 +126,8 @@ module Capybara
HaveSelector.new(:link, locator, options)
end
def have_button(locator)
HaveSelector.new(:button, locator)
def have_button(locator, options={})
HaveSelector.new(:button, locator, options)
end
def have_field(locator, options={})

View File

@ -9,9 +9,21 @@ Capybara::SpecHelper.spec '#has_button?' do
@session.should have_button(:'crap321')
end
it "should be true for disabled buttons if :disabled => true" do
@session.should have_button('Disabled button', :disabled => true)
end
it "should be false if the given button is not on the page" do
@session.should_not have_button('monkey')
end
it "should be false for disabled buttons by default" do
@session.should_not have_button('Disabled button')
end
it "should be false for disabled buttons if :disabled => false" do
@session.should_not have_button('Disabled button', :disabled => false)
end
end
Capybara::SpecHelper.spec '#has_no_button?' do
@ -24,7 +36,19 @@ Capybara::SpecHelper.spec '#has_no_button?' do
@session.should_not have_no_button('crap321')
end
it "should be true for disabled buttons if :disabled => true" do
@session.should_not have_no_button('Disabled button', :disabled => true)
end
it "should be false if the given button is not on the page" do
@session.should have_no_button('monkey')
end
it "should be false for disabled buttons by default" do
@session.should have_no_button('Disabled button')
end
it "should be false for disabled buttons if :disabled => false" do
@session.should have_no_button('Disabled button', :disabled => false)
end
end