I'm new to testing, so bear with me :)
I would like to test for random content on a page. For example, let's test the page for displaying the content either 'foo' or 'bar'.
Something like the below is what I'm trying to achieve
page.should (have_content('foo') || have_content('bar'))
Any ideas?
I don't know any ready to use Mather for you. But you can bake your own.
using satisfy:
page.should satisfy {|page| page.has_content?('foo') or page.has_content?('bar')}
or simple_matcher
def have_foo_or_bar
simple_matcher("check content has foo or bar") { |page| page.has_content?('foo') or page.has_content?('bar') }
end
describe page
it "should have foo or bar" do
page.should have_foo_or_bar
end
end
Edit: has_content
accepts regex, so you can check for page.should have_content(/foo|bar/)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With