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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -