Testing a link's target attribute with Capybara/RSpec -
i'm bit new rails/rspec/capybara, newbie question, google didn't as have hoped. hoping use
it { should have_link('link text', href: 'url', target: '_blank') } to write test link should open in new window, doesn't seem work. i've tried wrapping options hash in curly-braces:
it { should have_link('link text', {href: 'url', target: '_blank'}) } the test succeed regardless of presence or value of target attribute in actual page , link being tested. changing href attribute cause test failure expected. thought options hash have_link list of attributes test for. apparently i'm wrong, what's best way test single link it's target attribute? it's not use xpath search...
i not sure why code not work. have tried this:
find_link('link_text')[:href].should == 'url' find_link('link_text')[:target].should == '_blank'
Comments
Post a Comment