Permalink
Browse files

Use customer RSpec matchers in cucumber

  • Loading branch information...
1 parent d03fba8 commit 6d409dcf53c569074c2811370e6b75938a098ee1 @jnicklas jnicklas committed Feb 6, 2011
Showing with 20 additions and 0 deletions.
  1. +5 −0 features/capybara.feature
  2. +13 −0 features/step_definitions/capybara_steps.rb
  3. +2 −0 lib/capybara/cucumber.rb
@@ -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
@@ -9,3 +9,16 @@
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
@@ -1,7 +1,9 @@
require 'capybara'
require 'capybara/dsl'
+require 'capybara/rspec_matchers'
World(Capybara)
+World(Capybara::RSpecMatchers)
After do
Capybara.reset_sessions!

0 comments on commit 6d409dc

Please sign in to comment.