[rspec-users] Writing a matcher that accepts a block
dchelimsky at gmail.com
Sun Jan 9 23:07:43 EST 2011
On Jan 5, 2011, at 11:11 AM, Abhik Pramanik wrote:
> Hi all,
> I'm trying to emulate the have_tag matcher that used to be in rspec-rails. How would I do that with the rspec 2 interface?
> html.should have_tag("div") do
> RSpec::Matchers.define won't let me pass in a block. I could extend the RSpec::Matchers module but I'm not sure if that's the way to do it anymore. Any guidance would be helpful!
I'd recommend not doing this. Webrat and Capybara matchers both work very well for this and there is no need to roll your own by hacking RSpec.
html.should have_selector("div span")
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users