2011-08-30 75 views
2

我正嘗試通過使用Capybara爲我的應用程序+設計編寫集成測試的簽名。與設計一起使用水豚?

這是我到目前爲止有:

require 'spec_helper' 

describe "the signup process", :type => :request do 
    before :each do 
    @user_1 = Factory.create(:user, :email => '[email protected]', :password => 'iPassword') 
    end 

    it "signs me in" do 

    visit new_user_session_path 

    fill_in 'user[email]', :with => '[email protected]' 
    fill_in 'user[password]', :with => 'iPassword' 

    click_link_or_button 'Sign In' 

    end 


end 

這在流逝。這裏的問題是,它沒有檢查用戶是否登錄(cookie?),並且URL重定向正確?

如何將這些細節添加到此測試中?此外,對於無效登錄,我如何測試以確保閃光警報設置正確?

謝謝

回答

3

click_link_or_button後 '登錄' 添加:

current_path.should == 'your path' 
page.should have_content("Signed in successfully.") 

/support/devise.rb

RSpec.configure do |config| 
    config.include Devise::TestHelpers, :type => :controller 
end 
+0

謝謝,我看日誌。出於某種原因,它將重定向到example.com的任何想法? – AnApprentice

+0

你有devise.rb嗎?添加回答。 –

+0

我只是將它添加到:spec/support/devise.rb,它以前不存在。現在嘗試 – AnApprentice