我尝试用Travis CI测试我的Rails应用程序,并在我的控制器测试中得到了这个错误:
DaysController
GET 'index'
An error occurred in an after hook
NoMethodError: undefined method `original_path_set' for nil:NilClass
occurred at /home/travis/build/violarium/ruby-moon/vendor/bundle/ruby/2.1.0/gems/rspec-rails-2.14.2/lib/rspec/rails/view_rendering.rb:121:in `block (2 levels) in <module:ViewRendering>'
问题是,同一个测试在本地成功传递。
在此示例中,DaysController是一个关注的简单控制器 - 带有一些身份验证方法的模块:
module UserSession
extend ActiveSupport::Concern
private
# Sign in existent user
def sign_in(user)
cookies.permanent[:remember_token] = user.remember_token
end
# Clear cookies
def sign_out
cookies[:remember_token] = nil
end
# Get current signed in user or nil
def signed_in_user
@current_user ||= User.find_by(remember_token: cookies[:remember_token])
end
# Check if user is signed in
def signed_in?
!signed_in_user.nil?
end
included do
helper_method :signed_in?
end
end
答案 0 :(得分:1)
我不确定这是一个原因,但是当我添加字符串时问题就消失了:
cp config/travis/secrets.yml config/secrets.yml
它是新的铁路4.1存储机密的方式。
答案 1 :(得分:0)
这实际上可能是capybara / rspec-rails中的一个错误尝试升级到最新的rspec-rails和capybara。