【发布时间】:2010-08-15 07:02:03
【问题描述】:
我无法在黄瓜中显示模拟登录用户。
当用户登录后,他们可以发帖。
我的错误:
(::) failed steps (::)
undefined local variable or method `user' for #<Cucumber::Rails::World:0x85974df4> (NameError)
./features/step_definitions/tasklist_steps.rb:25:in `/^that I want to post a link$/'
features/tasklist.feature:10:in `Given that I want to post a link'
Failing Scenarios:
cucumber features/tasklist.feature:9 # Scenario: Submitting a Link
1 scenario (1 failed)
4 steps (1 failed, 1 skipped, 1 undefined, 1 passed)
0m0.432s
我的黄瓜:
Given /^I am an authenticated user$/ do
name = 'example'
email = 'example@example.com'
password = 'secret'
Given %{I have one user "#{name}" with email "#{email}" and password "#{password}"}
And %{I go to the user login page}
And %{I fill in "username" with "#{name}"}
And %{I fill in "password" with "#{password}"}
And %{I press "Login"}
end
Given /^that I want to post a link$/ do
title = 'My revolutionary post'
website_link = "http://www.google.com"
category = 'activism'
user = authenticated user
And %{I go to the new post page(#{user})}
如何模拟经过身份验证的用户?这样测试才能通过?
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 cucumber