[rspec-users] help me refactor a step for finding href in specific link

oren orengolan at gmail.com
Thu Apr 1 14:36:15 EDT 2010


thanks! i'll use cucumber list next time.

On Mar 31, 11:09 pm, David Chelimsky <dchelim... at gmail.com> wrote:
> On Mar 31, 2010, at 5:13 PM, Oren Golan wrote:
>
>
>
> > I want to verify the href is correct:
> > <p class="website">
> >    <a href="http://www.com.com">Website</a>
> > </p>
>
> > my step in the cucumber file:
> > And the "website" class should have "www.happyhour.com"
>
> > the step definition:
> > Then /^the "([^\"]*)" class should have "([^\"]*)"$/ do |link, url|
> >  response.should have_selector(".#{link}") do |site|
> >    site.inner_html.include?(url).should be_true
> >  end
> > end
>
> > it's doesn't look good and would like to hear suggestion for improving
> > it.
> > Thanks!
>
> Cucumber has its own list:http://groups.google.com/group/cukes, so you may get more responses there.
>
> I'd do something like this (incomplete and untested, but ....):
>
> And "Website" should link to "www.happyhour.com"
>
> Then /^"([^\"]*)" should link to "([^\"]*)"$/ do |text, href|
>   response.should have_xpath(<figure out the xpath including @href and text()>)
> end
>
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list