【问题标题】:Rails3 + Cucumber + Factory_girl_rails + Authlogic issueRails3 + Cucumber + Factory_girl_rails + Authlogic 问题
【发布时间】:2011-03-25 16:23:45
【问题描述】:

我整天都在为此苦苦挣扎!

在 GemFile 中,我有:

group :test do
    gem 'database_cleaner'
    gem 'cucumber-rails'
    gem 'cucumber'
    gem 'rspec-rails'
    gem 'spork'
    gem 'launchy'
    gem 'capybara' 
    gem 'factory_girl_rails'
end

在我的 login.feature 我有:

Feature: Login on my web site
  In order manage my account details
  As a security enthusiast
  I want to be able, to login and logout and view the superadmin button only when authorized

  Scenario: Check if login is working
    Given the following user records
      | email            | password |
      | julien@gmail.com | password |
      | bob@hotmail.com  | password |
    And I have 2 or more user records
    When I go to the login_url
    And I fill in "user_session_email" with "julien@gmail.com"
    And I fill in "user_session_password" with "password"
    And I press "Login"
    Then show me the page
    Then I should see "Logged in."

最后在我的 logins_steps.rb 文件中:

Given /^the following user records$/ do |table|
  table.hashes.each do |hash|
    u = Factory(:user, hash)
  end
end

当我手动操作时一切正常,但是当我运行 rake cucumber 时,字段已填写完毕,按下按钮,我会被重定向到主页,就像它应该做的那样,但问题是我没有登录,也没有看到任何闪烁消息(应该说已登录)

如果我尝试使用错误密码登录,我会被重定向到登录页面...

我不知道这个问题来自哪里,我尝试过使用 include Authlogic::TestCase 和 require "authlogic/test_case" 但没有其中有工作。

是 cookie、authlogic、factory_girl 还是 cucumber 问题,我真的不知道。

如果有人有想法,请随时给我留言!

干杯, 朱利安

【问题讨论】:

    标签: ruby-on-rails-3 cucumber authlogic factory-bot


    【解决方案1】:

    好的, 找到了答案, 您必须为您的域设置默认主机(设置为 www.example.com)。

    Capybara.default_host = "www.website.local"
    Capybara.server_port = 3000
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      相关资源
      最近更新 更多