Use expect..to instead of the `running` alias
This commit is contained in:
parent
875081fe56
commit
7e4d3b85f5
|
@ -76,15 +76,15 @@ Capybara::SpecHelper.spec "#attach_file" do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find file field \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.attach_file('does not exist', @test_file_path)
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a path that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
running { @session.attach_file('Image', '/no_such_file.png') }.should raise_error(Capybara::FileNotFound)
|
||||
expect { @session.attach_file('Image', '/no_such_file.png') }.to raise_error(Capybara::FileNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -69,17 +69,17 @@ Capybara::SpecHelper.spec "#check" do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find checkbox \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.check('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a disabled checkbox" do
|
||||
it "should raise an error" do
|
||||
running do
|
||||
expect do
|
||||
@session.check('Disabled Checkbox')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,17 +24,17 @@ Capybara::SpecHelper.spec "#choose" do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find radio button \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.choose('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a disabled radio button" do
|
||||
it "should raise an error" do
|
||||
running do
|
||||
expect do
|
||||
@session.choose('Disabled Radio')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -258,9 +258,9 @@ Capybara::SpecHelper.spec '#click_button' do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find button \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.click_button('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ Capybara::SpecHelper.spec '#click_link_or_button' do
|
|||
it "should raise an error" do
|
||||
@session.visit('/with_html')
|
||||
msg = "Unable to find link or button \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.click_link_or_button('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -60,9 +60,9 @@ Capybara::SpecHelper.spec '#click_link' do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find link \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.click_link('does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -112,8 +112,8 @@ Capybara::SpecHelper.spec '#click_link' do
|
|||
end
|
||||
|
||||
it "raise an error with links with no href" do
|
||||
running do
|
||||
expect do
|
||||
@session.click_link('No Href')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -116,26 +116,26 @@ Capybara::SpecHelper.spec "#fill_in" do
|
|||
after { Capybara.ignore_hidden_elements = false }
|
||||
it "should not find a hidden field" do
|
||||
msg = "Unable to find field \"Super Secret\""
|
||||
running do
|
||||
expect do
|
||||
@session.fill_in('Super Secret', :with => '777')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find field \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.fill_in('does not exist', :with => 'Blah blah')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "on a disabled field" do
|
||||
it "should raise an error" do
|
||||
running do
|
||||
expect do
|
||||
@session.fill_in('Disabled Text Field', :with => 'Blah blah')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ Capybara::SpecHelper.spec '#find_button' do
|
|||
end
|
||||
|
||||
it "should raise error if the button doesn't exist" do
|
||||
running do
|
||||
expect do
|
||||
@session.find_button('Does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ Capybara::SpecHelper.spec '#find_by_id' do
|
|||
end
|
||||
|
||||
it "should raise error if no element with id is found" do
|
||||
running do
|
||||
expect do
|
||||
@session.find_by_id('nothing_with_this_id')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,15 +14,15 @@ Capybara::SpecHelper.spec '#find_field' do
|
|||
end
|
||||
|
||||
it "should raise error if the field doesn't exist" do
|
||||
running do
|
||||
expect do
|
||||
@session.find_field('Does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
|
||||
it "should be aliased as 'field_labeled' for webrat compatibility" do
|
||||
@session.field_labeled('Dog').value.should == 'dog'
|
||||
running do
|
||||
expect do
|
||||
@session.field_labeled('Does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ Capybara::SpecHelper.spec '#find_link' do
|
|||
end
|
||||
|
||||
it "should raise error if the field doesn't exist" do
|
||||
running do
|
||||
expect do
|
||||
@session.find_link('Does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -102,9 +102,9 @@ Capybara::SpecHelper.spec '#find' do
|
|||
end
|
||||
|
||||
it "should raise ElementNotFound with a useful default message if nothing was found" do
|
||||
running do
|
||||
@session.find(:xpath, '//div[@id="nosuchthing"]').should be_nil
|
||||
end.should raise_error(Capybara::ElementNotFound, "Unable to find xpath \"//div[@id=\\\"nosuchthing\\\"]\"")
|
||||
expect do
|
||||
@session.find(:xpath, '//div[@id="nosuchthing"]').to be_nil
|
||||
end.to raise_error(Capybara::ElementNotFound, "Unable to find xpath \"//div[@id=\\\"nosuchthing\\\"]\"")
|
||||
end
|
||||
|
||||
it "should accept an XPath instance" do
|
||||
|
|
|
@ -154,7 +154,7 @@ Capybara::SpecHelper.spec "node" do
|
|||
node = @session.find(:css, '#reload-me')
|
||||
@session.click_link('Reload!')
|
||||
sleep(0.3)
|
||||
running { node.text.should == 'has been reloaded' }.should raise_error
|
||||
expect { node.text.to == 'has been reloaded' }.to raise_error
|
||||
end
|
||||
after { Capybara.automatic_reload = true }
|
||||
end
|
||||
|
@ -189,8 +189,8 @@ Capybara::SpecHelper.spec "node" do
|
|||
node = @session.all(:css, '#the-list li')[1]
|
||||
@session.click_link('Fetch new list!')
|
||||
sleep(0.3)
|
||||
running { node.text.should == 'Foo' }.should raise_error
|
||||
running { node.text.should == 'Bar' }.should raise_error
|
||||
expect { node.text.to == 'Foo' }.to raise_error
|
||||
expect { node.text.to == 'Bar' }.to raise_error
|
||||
end
|
||||
|
||||
it "should reload nodes with options" do
|
||||
|
|
|
@ -62,26 +62,26 @@ Capybara::SpecHelper.spec "#select" do
|
|||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find select box \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.select('foo', :from => 'does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an option that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find option \"Does not Exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.select('Does not Exist', :from => 'form_locale')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "on a disabled select" do
|
||||
it "should raise an error" do
|
||||
running do
|
||||
expect do
|
||||
@session.select('Should not see me', :from => 'Disabled Select')
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,25 +48,25 @@ Capybara::SpecHelper.spec "#unselect" do
|
|||
|
||||
context "with single select" do
|
||||
it "should raise an error" do
|
||||
running { @session.unselect("English", :from => 'form_locale') }.should raise_error(Capybara::UnselectNotAllowed)
|
||||
expect { @session.unselect("English", :from => 'form_locale') }.to raise_error(Capybara::UnselectNotAllowed)
|
||||
end
|
||||
end
|
||||
|
||||
context "with a locator that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find select box \"does not exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.unselect('foo', :from => 'does not exist')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
|
||||
context "with an option that doesn't exist" do
|
||||
it "should raise an error" do
|
||||
msg = "Unable to find option \"Does not Exist\""
|
||||
running do
|
||||
expect do
|
||||
@session.unselect('Does not Exist', :from => 'form_underwear')
|
||||
end.should raise_error(Capybara::ElementNotFound, msg)
|
||||
end.to raise_error(Capybara::ElementNotFound, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,23 +87,23 @@ Capybara::SpecHelper.spec '#within' do
|
|||
end
|
||||
|
||||
it "should raise an error if the scope is not found on the page" do
|
||||
running do
|
||||
expect do
|
||||
@session.within("//div[@id='doesnotexist']") do
|
||||
end
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end
|
||||
|
||||
it "should restore the scope when an error is raised" do
|
||||
running do
|
||||
expect do
|
||||
@session.within("//div[@id='for_bar']") do
|
||||
running do
|
||||
running do
|
||||
expect do
|
||||
expect do
|
||||
@session.within(".//div[@id='doesnotexist']") do
|
||||
end
|
||||
end.should raise_error(Capybara::ElementNotFound)
|
||||
end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
|
||||
end.to raise_error(Capybara::ElementNotFound)
|
||||
end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
|
||||
end
|
||||
end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
|
||||
end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
|
||||
end
|
||||
|
||||
it "should fill in a field and click a button" do
|
||||
|
|
|
@ -47,9 +47,9 @@ end
|
|||
describe Capybara::Session do
|
||||
context 'with non-existant driver' do
|
||||
it "should raise an error" do
|
||||
running {
|
||||
expect {
|
||||
Capybara::Session.new(:quox, TestApp).driver
|
||||
}.should raise_error(Capybara::DriverNotFoundError)
|
||||
}.to raise_error(Capybara::DriverNotFoundError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -127,9 +127,9 @@ describe Capybara::RackTest::Driver do
|
|||
end
|
||||
|
||||
it "should not follow more than 6 redirects" do
|
||||
running do
|
||||
expect do
|
||||
@driver.visit("/redirect/6/times")
|
||||
end.should raise_error(Capybara::InfiniteRedirectError)
|
||||
end.to raise_error(Capybara::InfiniteRedirectError)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -144,9 +144,9 @@ describe Capybara::RackTest::Driver do
|
|||
end
|
||||
|
||||
it "should not follow more than 21 redirects" do
|
||||
running do
|
||||
expect do
|
||||
@driver.visit("/redirect/22/times")
|
||||
end.should raise_error(Capybara::InfiniteRedirectError)
|
||||
end.to raise_error(Capybara::InfiniteRedirectError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,9 +12,9 @@ describe Capybara::Server do
|
|||
end
|
||||
|
||||
it "should do nothing when no server given" do
|
||||
running do
|
||||
expect do
|
||||
@server = Capybara::Server.new(nil).boot
|
||||
end.should_not raise_error
|
||||
end.not_to raise_error
|
||||
end
|
||||
|
||||
it "should bind to the specified host" do
|
||||
|
|
|
@ -26,8 +26,6 @@ end
|
|||
|
||||
require 'capybara/spec/spec_helper'
|
||||
|
||||
alias :running :lambda
|
||||
|
||||
module TestSessions
|
||||
RackTest = Capybara::Session.new(:rack_test, TestApp)
|
||||
Selenium = Capybara::Session.new(:selenium, TestApp)
|
||||
|
|
Loading…
Reference in New Issue