mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
cf1aa4d073
This way, implementations of other drivers can use the specs to verify that they are working correctly.
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
module CheckSpec
|
|
shared_examples_for "check" do
|
|
|
|
describe "#check" do
|
|
before do
|
|
@session.visit('/form')
|
|
end
|
|
|
|
describe "'checked' attribute" do
|
|
it "should be true if checked" do
|
|
@session.check("Terms of Use")
|
|
@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked'].should be_true
|
|
end
|
|
|
|
it "should be false if unchecked" do
|
|
@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked'].should be_false
|
|
end
|
|
end
|
|
|
|
it "should check a checkbox by id" do
|
|
@session.check("form_pets_cat")
|
|
@session.click_button('awesome')
|
|
extract_results(@session)['pets'].should include('dog', 'cat', 'hamster')
|
|
end
|
|
|
|
it "should check a checkbox by label" do
|
|
@session.check("Cat")
|
|
@session.click_button('awesome')
|
|
extract_results(@session)['pets'].should include('dog', 'cat', 'hamster')
|
|
end
|
|
|
|
context "with a locator that doesn't exist" do
|
|
it "should raise an error" do
|
|
running { @session.check('does not exist') }.should raise_error(Capybara::ElementNotFound)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|