Use customer RSpec matchers in cucumber

This commit is contained in:
Jonas Nicklas 2011-02-06 14:44:43 +01:00
parent d03fba859b
commit 6d409dcf53
3 changed files with 20 additions and 0 deletions

View File

@ -16,3 +16,8 @@ Feature: Capybara's cucumber integration
Scenario: selenium tag
When I visit the root page
Then Capybara should use the "selenium" driver
Scenario: matchers
When I visit the root page
And I use a matcher that fails
Then the failing exception should be nice

View File

@ -9,3 +9,16 @@ end
Then /^Capybara should use the "([^"]*)" driver$/ do |driver|
Capybara.current_driver.should == driver.to_sym
end
When /^I use a matcher that fails$/ do
begin
page.should have_css('h1#doesnotexist')
rescue StandardError => e
@error_message = e.message
end
end
Then /^the failing exception should be nice$/ do
@error_message.should =~ %r(expected css \"h1#doesnotexist\" to return)
end

View File

@ -1,7 +1,9 @@
require 'capybara'
require 'capybara/dsl'
require 'capybara/rspec_matchers'
World(Capybara)
World(Capybara::RSpecMatchers)
After do
Capybara.reset_sessions!