Added have_select and have_table matchers

This commit is contained in:
Jonas Nicklas 2011-03-25 10:46:31 +00:00
parent 2e5852b5a6
commit e9814d70c8
2 changed files with 35 additions and 2 deletions

View File

@ -134,5 +134,13 @@ module Capybara
def have_unchecked_field(locator)
HaveMatcher.new(:unchecked_field, locator)
end
def have_select(locator, options={})
HaveMatcher.new(:select, locator, options)
end
def have_table(locator, options={})
HaveMatcher.new(:table, locator, options)
end
end
end

View File

@ -420,7 +420,32 @@ describe Capybara::RSpecMatchers do
end
end
describe "have_select matcher"
describe "have_table matcher"
describe "have_select matcher" do
let(:html) { '<label>Select Box<select></select></label>' }
it "passes if there is such a select" do
html.should have_select('Select Box')
end
it "fails if there is no such select" do
expect do
html.should have_select('No such Select box')
end.to raise_error(/expected select "No such Select box"/)
end
end
describe "have_table matcher" do
let(:html) { '<table><caption>Lovely table</caption></table>' }
it "passes if there is such a select" do
html.should have_table('Lovely table')
end
it "fails if there is no such select" do
expect do
html.should have_table('No such Table')
end.to raise_error(/expected table "No such Table"/)
end
end
end