mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Added has_button?
This commit is contained in:
parent
5150ad429f
commit
fe558b2f01
3 changed files with 41 additions and 0 deletions
|
@ -177,6 +177,14 @@ module Capybara
|
|||
has_no_xpath?(XPath.link(locator))
|
||||
end
|
||||
|
||||
def has_button?(locator)
|
||||
has_xpath?(XPath.button(locator))
|
||||
end
|
||||
|
||||
def has_no_button?(locator)
|
||||
has_no_xpath?(XPath.button(locator))
|
||||
end
|
||||
|
||||
def has_field?(locator, options={})
|
||||
has_xpath?(XPath.field(locator, options))
|
||||
end
|
||||
|
|
32
spec/dsl/has_button_spec.rb
Normal file
32
spec/dsl/has_button_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
shared_examples_for "has_button" do
|
||||
describe '#has_button?' do
|
||||
before do
|
||||
@session.visit('/form')
|
||||
end
|
||||
|
||||
it "should be true if the given button is on the page" do
|
||||
@session.should have_button('med')
|
||||
@session.should have_button('crap321')
|
||||
end
|
||||
|
||||
it "should be false if the given button is not on the page" do
|
||||
@session.should_not have_button('monkey')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_no_button?' do
|
||||
before do
|
||||
@session.visit('/form')
|
||||
end
|
||||
|
||||
it "should be true if the given button is on the page" do
|
||||
@session.should_not have_no_button('med')
|
||||
@session.should_not have_no_button('crap321')
|
||||
end
|
||||
|
||||
it "should be false if the given button is not on the page" do
|
||||
@session.should have_no_button('monkey')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -53,6 +53,7 @@ shared_examples_for "session" do
|
|||
it_should_behave_like "has_css"
|
||||
it_should_behave_like "has_xpath"
|
||||
it_should_behave_like "has_link"
|
||||
it_should_behave_like "has_button"
|
||||
it_should_behave_like "has_field"
|
||||
it_should_behave_like "select"
|
||||
it_should_behave_like "uncheck"
|
||||
|
|
Loading…
Add table
Reference in a new issue