2011-08-30 79 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