Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (22 sloc) 0.834 kb
Feature: define matcher with fluent interface
Use the chain() method to define matchers with a fluent interface.
Scenario: chained method with argumetn
Given a file named "between_spec.rb" with:
"""
require 'rspec/expectations'
RSpec.configuration.generated_docstring_format = :indicative
RSpec::Matchers.define :be_bigger_than do |first|
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`
Then the output should contain "1 example, 0 failures"
And the output should contain "is bigger than 4"
Jump to Line
Something went wrong with that request. Please try again.