Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from avh4/patch-2
Update matchers.rb template for rspec 2
- Loading branch information
Showing
1 changed file
with
11 additions
and
9 deletions.
There are no files selected for viewing
20 changes: 11 additions & 9 deletions
20
rubygems_generators/install_cucumber/templates/features/support/matchers.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
module Matchers | ||
def contain(expected) | ||
simple_matcher("contain #{expected.inspect}") do |given, matcher| | ||
matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}" | ||
matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}" | ||
given.index expected | ||
end | ||
RSpec::Matchers.define :contain do |expected| | ||
match do |actual| | ||
actual.index expected | ||
end | ||
|
||
failure_message_for_should do |actual| | ||
"expected #{actual.inspect} to contain #{expected.inspect}" | ||
end | ||
end | ||
|
||
World(Matchers) | ||
failure_message_for_should_not do |actual| | ||
"expected #{actual.inspect} not to contain #{expected.inspect}" | ||
end | ||
end |