-
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22d41fb
commit 08265c8
Showing
1 changed file
with
8 additions
and
11 deletions.
There are no files selected for viewing
19 changes: 8 additions & 11 deletions
19
features/matchers/define_matcher_with_fluent_interface.feature
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,27 +1,24 @@ | ||
Feature: define matcher | ||
Feature: define matcher with fluent interface | ||
|
||
In order to express my domain clearly in my code examples | ||
As an RSpec user | ||
I want to define matchers with fluent interfaces | ||
Use the chain() method to define matchers with a fluent interface. | ||
|
||
Scenario: one additional method | ||
Scenario: chained method with argumetn | ||
Given a file named "between_spec.rb" with: | ||
""" | ||
RSpec::Matchers.define :be_bigger_than do |first| | ||
def but_smaller_than(second) | ||
@second = second | ||
self | ||
end | ||
match do |actual| | ||
(actual > first) && (actual < @second) | ||
end | ||
chain :but_smaller_than do |second| | ||
@second = second | ||
end | ||
end | ||
describe 5 do | ||
it { should be_bigger_than(4).but_smaller_than(6) } | ||
end | ||
""" | ||
When I run "rspec ./between_spec.rb --format documentation" | ||
When I run "rspec between_spec.rb --format documentation" | ||
Then the output should contain "1 example, 0 failures" | ||
And the output should contain "should be bigger than 4" |