Reputation: 9754
I'm fairly new to Rspec so apologies if this is a really simple question:
I want to check that there is some link on the page that has a link to a pdf.
Essentially something along the lines of:
rendered.should have_selector :a[href=~/\.pdf/]
but I'm getting the error undefined variable or method href.
Is there someway to do:
attribute.should =~ /regex/
Upvotes: 2
Views: 1723
Reputation: 7164
using has_selector should do a substring match for you, so you could always try doing something like this:
response.should have_selector("a", :href => ".pdf")
Upvotes: 1
Reputation: 222118
You can use the CSS3 Substring matching attribute selectors for this case.
rendered.should have_selector 'a[href$=.pdf]'
Upvotes: 2