I want to testing my controller posts
and when I running Rspec
test, shell show me an error
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'
this is my 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
how fix?