1
基本上,我希望場景大綱循環遍歷所有各種組合,以便我不必編寫一堆場景。我想讓它訪問起始頁面,然後檢查鏈接是否存在,但是我遇到了障礙。創建動態cucumber_steps以檢查頁面上的鏈接
黃瓜功能
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 |
黃瓜功能步驟
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
我需要使用類似:
response.should have_selector('a,':href => link_path,
:content => link)
但不會作爲工作動態它只會檢查link_path ...
這絕對看起來像我所需要的,但我將如何使用它? link = send(「#{link} _path」)然後:href =>鏈接? – BrianJakovich
@ Avc1298:是的,就是這樣。試試看。 –