Re: [rspec-users] how can I do an "or" within the context of a matcher?
You're looking for Custom Matchers: https://github.com/dchelimsky/rspec/wiki/Custom-Matchers Em 15-05-2012 03:47, Patrick J. Collins escreveu: Capybara has two methods: page.has_button? and page.has_link? ... I am wondering, how can I make a helper method that will be satisfied by one or the other? In other words, I want to be able to do: page.should have_link_or_button("blah") def have_link_or_button(locator) have_link(locator) || have_button(locator) end But that doesn't work... Is there any way to do this? Patrick J. Collins ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] how can I do an "or" within the context of a matcher?
On May 15, 2012, at 12:47 AM, Patrick J. Collins wrote: > Capybara has two methods: > > page.has_button? > > and > > page.has_link? > > ... I am wondering, how can I make a helper method that will be > satisfied by one or the other? In other words, I want to be able to do: > > page.should have_link_or_button("blah") > > def have_link_or_button(locator) > have_link(locator) || have_button(locator) > end > > But that doesn't work... Is there any way to do this? > > Patrick J. Collins > http://collinatorstudios.com > > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users You need a custom matcher, something like this: RSpec::Matchers.define :have_link_or_button do |locator| match do |page| page.has_button?(locator) || page.has_link?(locator) end end BTW, I believe Capybara has a method that checks for a button *or* link - look into that. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] overview of how rspec was designed
On Mon, May 14, 2012 at 2:23 PM, S Ahmed wrote: > Other than jumping into the codebase myself, I was wondering if anyone has > done a high-level (or better yet low level) write-up on how rspec works > under the covers? The RSpec Book has a fairly deep discussion on the inner workings. Other than that, there are some things you can get from the docs, but there is not a central "this is how RSpec works" document that I've written or am aware of. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users