2011-03-25 57 views
0

我一直在這一整天都在苦苦掙扎!Rails3 +黃瓜+ Factory_girl_rails + Authlogic問題

在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我:

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

一切:

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 | 
     | [email protected] | password | 
     | [email protected] | password | 
    And I have 2 or more user records 
    When I go to the login_url 
    And I fill in "user_session_email" with "[email protected]" 
    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文件

最後當我手工操作時運作良好,但是當我運行耙黃瓜,填寫的字段,按鈕被按下,我被重定向到主頁像它應該,但問題是,我沒有登錄,也沒有看到任何Flash消息(它應該說登錄)

如果我試圖用錯誤的密碼登錄,我得到重定向到登錄頁面...

我不知道在哪裏這個問題從何而來,我試着玩的包括Authlogic :: TestCase需要「authlogic/test_case」但他們都沒有工作。

這是一個cookie,authlogic,factory_girl或黃瓜問題,我真的不知道。

如果有人有想法,請隨時給我留言!

乾杯, 朱利安

回答

1

OK, 找到了答案, 您必須設置默認主機(被設置爲www.example.com)到您的域。

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