Jonathan Rochkind
2011-Mar-15 15:27 UTC
[rspec-users] custom matcher and yielding too block
Using the ''new'' way of defining custom matchers explained here: https://github.com/dchelimsky/rspec/wiki/Custom-Matchers I''m having trouble figuring out how to write a custom matcher that yields an object to a block where more matchers can be called on it. For instance, I''d like my actual spec to look something like this: something.should custom_matcher do | x | x.should be_something x.should include(something_or_other) end You get the idea? Can I create a custom matcher that does that? I''m having trouble figuring out how.
On Mar 15, 2011, at 10:27 AM, Jonathan Rochkind wrote:> Using the ''new'' way of defining custom matchers explained here: https://github.com/dchelimsky/rspec/wiki/Custom-Matchers > > I''m having trouble figuring out how to write a custom matcher that yields an object to a block where more matchers can be called on it. > > For instance, I''d like my actual spec to look something like this: > > something.should custom_matcher do | x | > x.should be_something > x.should include(something_or_other) > end > > You get the idea? Can I create a custom matcher that does that? I''m having trouble figuring out how.Currently not supported, but I think it should be. Would you mind making a feature request at http://github.com/rspec/rspec-expectations/issues? Thx, David