Rspec无法正常工作:无法找到匹配的行

时间:2015-02-04 14:49:21

标签: ruby-on-rails rspec

我正在编写一个执行此操作的rspec

require 'rails_helper' 
 feature 'People can sign-in' do

  include TestFactories
  include Devise::TestHelpers

 scenario 'Log in successfully' do
 # request.env["HTTP_REFERER"] = '/'
 visit root_path
 @user = authenticated_user #defined in test_factories.rb
 sign_in @user
 sign_in @user
  end
 end

但是当我尝试运行它时,我收到以下错误:

 Failure/Error: Unable to find matching line from backtrace
 NoMethodError:
   undefined method `env' for nil:NilClass

我已经尝试添加:

request.env["HTTP_REFERER"] = '/'

但这没有用。 Ant提供了我应该做些什么才能让它工作?

1 个答案:

答案 0 :(得分:-1)

我刚遇到同样的错误。

这是我的快速修复,根据您的需要定制。

post "/some/page", {:first_name => "john", :last_name => "doe"}, {:referer => '/some/page'}