Oren Golan
2010-Mar-31 22:13 UTC
[rspec-users] help me refactor a step for finding href in specific link
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! -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2010-Mar-31 23:09 UTC
[rspec-users] help me refactor a step for finding href in specific link
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
oren
2010-Apr-01 18:36 UTC
[rspec-users] help me refactor a step for finding href in specific link
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