I tried to test my Rails application with Travis CI and got this errors in my controller tests:

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>'

The problem is, that same test locally passing successfully.

In this example DaysController is a simple controller with concern - module with some authentication methods:

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
有帮助吗?

解决方案

I don't sure that this was a reason, but problem disappeared when I added the string:

cp config/travis/secrets.yml config/secrets.yml

It's new rails 4.1 way to store secrets.

其他提示

This might actually be a bug in capybara/rspec-rails Try upgrading to the latest rspec-rails and capybara.

See https://github.com/rspec/rspec-rails/issues/860 for more details.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top