Creating dynamic cucumber_steps to check for links on a page

不打扰是莪最后的温柔 提交于 2019-12-13 00:51:56

问题


Basically I want the scenario outline to loop through all of the various combinations so that I don't have to write a bunch of scenarios. I want to have it visit the starting page and then check to see if the links are there however I've hit a barrier.

Cucumber feature

    Scenario Outline: As a user I need links in order to navigate the site
    Given I am a '<user>'
    When I am at the <page> page
    Then I should see a link to '<link>'

    Scenarios: As a user that is not logged in
        |       user         |   page    |  link   |
        | not_signed_in_user |    /      | contact |

Cucumber Feature Steps

    Given /^I am a 'not_signed_in_user'$/ do
         @user = nil
    end

    When /^I am at the (.+) page$/ do |starting_page|
         visit starting_page
    end

    Then /^I should see a link to (.+)$/ do |link|
         pending
    end

I need to use something like:

    response.should have_selector('a,':href => link_path,
                                     :content => link )

but that won't work dynamically as it will just check for link_path...


回答1:


It sounds like you want to use send("#{link}_path") here. That would generate the link using the routing helper which I think it is what you want.



来源:https://stackoverflow.com/questions/6810287/creating-dynamic-cucumber-steps-to-check-for-links-on-a-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!