我正在尝试使用Capybara为我的app + devise编写一个登录集成测试。
这是我到目前为止所知道的:
require 'spec_helper'
describe "the signup process", :type => :request do
before :each do
@user_1 = Factory.create(:user, :email => 'bob@golden.com', :password => 'iPassword')
end
it "signs me in" do
visit new_user_session_path
fill_in 'user[email]', :with => 'bob@golden.com'
fill_in 'user[password]', :with => 'iPassword'
click_link_or_button 'Sign In'
end
end
这已经过去了。这里的问题是它没有检查用户是否已登录(cookie?)以及url重定向是否正确?
如何将这些详细信息添加到此测试中?另外,对于无效的登录,我如何测试以确保闪存警报设置正确?
谢谢
发布于 2011-08-31 02:29:27
在click_link_or_button 'Sign In‘之后添加:
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
https://stackoverflow.com/questions/7247882
复制相似问题