title: Message: Failure/Error: require File.expand_path('../../config/environment', __FILE__)
body: <p>First i read other posts of users with similiar problems, but couldnt come along where my mistake is. I wanted to start a test with RSpec on the following file:</p>
  
  <p>dashboard_view_spec.rb:</p>
  
  <pre><code>require 'rails_helper'
  
  RSpec.feature "Dashboard", type: :feature do 
  before(:each) do
  @current_user = User.create!(email: "xyz@xyz.com", password: "xyz123")
  sign_in_with(@current_user.email,@current_user.password)
  end
  
  #NAV BAR RSPEC TEST
  scenario 'Home bar nav link present' do
  visit "/"
  expect(page).to have_text('Home')
  end
  
  scenario 'How it work nav bar link present' do
  visit "/"
  expect(page).to have_text('How it work')
  end
  
  scenario 'Support nav bar link present' do
  visit "/"
  expect(page).to have_text('Support')
  end
  
  end
  </code></pre>
  
  <p>On rails_helper.rb on the top:</p>
  
  <pre><code># This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV['RAILS_ENV'] ||= 'test'
  
  require File.expand_path('../../config/environment', __FILE__)
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  # Prevent database truncation if the environment is production
  abort("The Rails environment is running in production mode!") if   Rails.env.production?
  
  require 'rake'
  require 'spec_helper'
  require 'rspec/rails'
  require 'shoulda/matchers'
  require 'capybara/rails'
  require 'capybara/rspec'
  require 'rspec/retry'
  require 'devise'
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Failure/Error: require File.expand_path('../../config/environment', __FILE__)
  
  NoMethodError:
  undefined method `[]' for nil:NilClass
  # ./config/initializers/devise.rb:258:in `block in &lt;top (required)&gt;'
  # ./config/initializers/devise.rb:5:in `&lt;top (required)&gt;'
  # ./config/environment.rb:5:in `&lt;top (required)&gt;'
  # ./spec/rails_helper.rb:4:in `require'
  # ./spec/rails_helper.rb:4:in `&lt;top (required)&gt;'
  # ./spec/views/dashboard_view_spec.rb:1:in `require'
  # ./spec/views/dashboard_view_spec.rb:1:in `&lt;top (required)&gt;'
  No examples found.
  
  Randomized with seed 14549
  </code></pre>
  
  <p>Then the command i used on the terminal</p>
  
  <pre><code> bundle exec rspec spec/views/dashboard_view_spec.rb
  </code></pre>
  
  <p>After watching the documentation of testing with Devise i changed the code in               <em>dashboard_view_spec.rb</em> and used to <strong>sign_in</strong> as a <strong>user</strong> and got the same error message. </p>
  
  <p>Line 258 of devise.rb</p>
  
  <pre><code> config.omniauth :facebook, Rails.application.secrets.facebook[:key],  Rails.application.secrets.facebook[:secret], scope: 'email', info_fields: 'email, name'
  </code></pre>
  
  <p>In the gemfile</p>
  
  <pre><code>group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger     console
   gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
   # Adds support for Capybara system testing and selenium driver
   gem 'capybara', '~&gt; 2.13'
   gem 'selenium-webdriver'
   gem 'rspec-rails', '~&gt; 3.8'
   gem 'factory_girl_rails'
   gem 'faker'
   gem 'database_cleaner'
  end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>group :development do
  # Access an IRB console on exception pages or by using &lt;%= console %&gt;    anywhere in the code.
  gem 'web-console', '&gt;= 3.3.0'
  gem 'listen', '&gt;= 3.0.5', '&lt; 3.2'
  # Spring speeds up development by keeping your application running in the  background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~&gt; 2.0.0'
  end
  </code></pre>