CheckSpec module removed. It's all global now.

This commit is contained in:
Jonas Nicklas 2010-08-27 20:40:25 +02:00
parent e857058b9a
commit 34a9030d3e
1 changed files with 51 additions and 53 deletions

View File

@ -1,67 +1,65 @@
module CheckSpec
shared_examples_for "check" do
describe "#check" do
before do
@session.visit('/form')
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
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
it "should be false if unchecked" do
@session.find(:xpath, "//input[@id='form_terms_of_use']")['checked'].should be_false
end
end
describe "checking" do
it "should not change an already checked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
@session.check('form_pets_dog')
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
end
describe "checking" do
it "should not change an already checked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
@session.check('form_pets_dog')
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
end
it "should check an unchecked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
@session.check('form_pets_cat')
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_true
end
end
it "should check an unchecked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
@session.check('form_pets_cat')
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_true
end
describe "unchecking" do
it "should not change an already unchecked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
@session.uncheck('form_pets_cat')
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
end
describe "unchecking" do
it "should not change an already unchecked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
@session.uncheck('form_pets_cat')
@session.find(:xpath, "//input[@id='form_pets_cat']")['checked'].should be_false
end
it "should uncheck a checked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
@session.uncheck('form_pets_dog')
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_false
end
it "should uncheck a checked checkbox" do
@session.find(:xpath, "//input[@id='form_pets_dog']")['checked'].should be_true
@session.uncheck('form_pets_dog')
@session.find(:xpath, "//input[@id='form_pets_dog']")['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 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
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
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