mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Allows passing options through has_button? to has_selector?
This enables assertions on the presence of disabled buttons by doing: assert has_button?('Button text', :disabled => true) in a similar way to: find_field("Disabled Checkbox", :disabled => true)
This commit is contained in:
parent
ac863cedf7
commit
e7b72c72ec
3 changed files with 30 additions and 6 deletions
|
@ -280,8 +280,8 @@ module Capybara
|
||||||
# @param [String] locator The text, value or id of a button to check for
|
# @param [String] locator The text, value or id of a button to check for
|
||||||
# @return [Boolean] Whether it exists
|
# @return [Boolean] Whether it exists
|
||||||
#
|
#
|
||||||
def has_button?(locator)
|
def has_button?(locator, options={})
|
||||||
has_selector?(:button, locator)
|
has_selector?(:button, locator, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -292,8 +292,8 @@ module Capybara
|
||||||
# @param [String] locator The text, value or id of a button to check for
|
# @param [String] locator The text, value or id of a button to check for
|
||||||
# @return [Boolean] Whether it doesn't exist
|
# @return [Boolean] Whether it doesn't exist
|
||||||
#
|
#
|
||||||
def has_no_button?(locator)
|
def has_no_button?(locator, options={})
|
||||||
has_no_selector?(:button, locator)
|
has_no_selector?(:button, locator, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -126,8 +126,8 @@ module Capybara
|
||||||
HaveSelector.new(:link, locator, options)
|
HaveSelector.new(:link, locator, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def have_button(locator)
|
def have_button(locator, options={})
|
||||||
HaveSelector.new(:button, locator)
|
HaveSelector.new(:button, locator, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def have_field(locator, options={})
|
def have_field(locator, options={})
|
||||||
|
|
|
@ -9,9 +9,21 @@ Capybara::SpecHelper.spec '#has_button?' do
|
||||||
@session.should have_button(:'crap321')
|
@session.should have_button(:'crap321')
|
||||||
end
|
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
|
it "should be false if the given button is not on the page" do
|
||||||
@session.should_not have_button('monkey')
|
@session.should_not have_button('monkey')
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
Capybara::SpecHelper.spec '#has_no_button?' do
|
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')
|
@session.should_not have_no_button('crap321')
|
||||||
end
|
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
|
it "should be false if the given button is not on the page" do
|
||||||
@session.should have_no_button('monkey')
|
@session.should have_no_button('monkey')
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue