1
Я хочу испытывать мой контроллер posts
и когда я работает Rspec
тест, скорлупа показать мне ошибкуNoMethodError: неопределенный метод `окр» для ноль: NilClass
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `env' for nil:NilClass
# /home/weare138/.rvm/gems/ruby-2.1.5/gems/devise-3.4.1/lib/devise/test_helpers.rb:24:in `setup_controller_for_warden'
это мой spec/requests/posts_spec.rb
require 'rails_helper'
describe "Posts" do
describe "GET /posts" do
it "works! (now write some real specs)" do
user = FactoryGirl.create(:user, role: 'admin')
sign_in user
end
end
end
UPD
rails_helper
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include Devise::TestHelpers, :type => :request
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
end
как исправить?
Благодарю вас, я нахожу этот вопрос, но я не понял с этим желанием. – vveare138
. Вы добавили эти помощники в свой тестовый env, как указано в readme https://github.com/plataformatec/devise#test- помощники? – rastasheep
Да, я добавил.Обновленный вопрос – vveare138