mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Added have_select and have_table matchers
This commit is contained in:
parent
2e5852b5a6
commit
e9814d70c8
2 changed files with 35 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue