Added has_button?

This commit is contained in:
Jonas Nicklas 2010-01-18 21:40:59 +01:00
parent 5150ad429f
commit fe558b2f01
3 changed files with 41 additions and 0 deletions

View File

@ -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

View 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

View File

@ -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"