Can't wait, I'll keep my eyes open for a 3.1 beta. Really enjoying Rspec 3.
Actually I can just point at the master branch and try it out now.
Many thanks.
On Friday, 15 August 2014 21:39:03 UTC+1, Myron Marston wrote:
>
> On Friday, August 15, 2014 9:49:47 AM UTC-7, Kris Leech wrote:
>>
>> Is it possible to chain two matchers and not have to yield the block
>> given to expect twice?
>>
>> The problem is yielding the block twice changes the test.
>>
>> class FirstMatcher
>> def matches?(block)
>> @result = record_something do
>> block.call # block called for first time
>> end
>> return true
>> end
>>
>> def supports_block_expectations?
>> true
>> end
>>
>> def second_matcher?
>> SecondMatcher.new
>> end
>> end
>>
>> class SecondMatcher
>> def matches?(block)
>> @result = record_something do
>> block.call # block called for second time, can I get the original
>> @result somehow?
>> end
>> return true
>> end
>>
>> def supports_block_expectations?
>> true
>> end
>> end
>>
>>
>> # usage
>>
>> expect { something }.to first_matcher.second_matcher
>>
>> Many thanks, Kris.
>>
>
> In RSpec 3.0, there's not. In 3.1, there will be:
>
> https://github.com/rspec/rspec-expectations/pull/567
>
> Use the `and` chaining:
>
> expect { }.to first_matcher.and second_matcher
>
> ...and it should just work.
>
> Myron
>
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/520b585c-fd97-4aee-96d9-aed6b72e247c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.