ruby on rails - How can I test with a certain word is a link or not with Cucumber? -


i custom step:

then should see link 'foo' 

and opposite:

but should not see link 'foo' 

in page can have like:

lorem foo bar 

or alternatively

lorem <a href=''>foo</a> bar 

i need test when 'foo' link , when isn't. thank you.

try (i haven't tried running it, minor tweaks might needed):

then /^i should see link "([^\"]*)"$/ |linked_text|   # afaik raises exception if link not found   find_link(linked_text) end  /^i should not see link "([^\"]*)"$/ |linked_text|   begin     find_link(linked_text)     raise "oh no, #{linked_text} link!"   rescue     # cool, text not link   end end 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -