使用设计的黄瓜测试总是返回无效的电子邮件

时间:2014-06-01 13:13:20

标签: ruby-on-rails devise cucumber

我正在使用Cucumber来测试我的设计登录,然后在登录成功后检查我的网页中是否存在文本。问题是,即使使用User.create后,我的应用程序中始终会收到无效的用户名/密码。我使用Selenium驱动浏览器并检查字段是否填写正确,它们是!但登录始终会产生无效的用户名/密码!请帮帮我吧!步骤定义代码如下 -

$email = 'test@pinster.com'
$password = 'secret12skdfgsjhdf'
$name = 'stub_name'

Given(/^I am a new authenticated user$/) do
  User.new(:email => $email, :password => $password, :password_confirmation => $password, :name=> $name).save!
end

When(/^I click on sign in on the home page$/) do
  visit root_path
  click_link 'Sign in'
end

When(/^I fill up my details on the sign in page$/) do
  fill_in "Email", :with => $email
  sleep(4)
  fill_in "Password", :with => $password
  sleep(3)
  click_button('Sign in')
end

Then(/^I should find content for "(.*?)"$/) do |arg1|
  page.should have_content(arg1)
end

0 个答案:

没有答案