Есть элементарный тест
require 'rails_helper'
RSpec.describe "Test if root exists", type: :request do
describe "GET /" do
it "visits root" do
visit root_url
expect(current_url).to eql(root_url)
end
end
end
Когда запускаю, получаю ошибку
1) Test if root exists GET / visits root
Failure/Error: visit root_url
NoMethodError:
undefined method `empty?' for nil:NilClass
# ./spec/requests/root_spec.rb:6:in `block (3 levels) in '
spec/spec_helper.rb
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
end
spec/rails_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl_rails'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.include Rails.application.routes.url_helpers
config.infer_spec_type_from_file_location!
config.before(:suite) { DatabaseCleaner.clean_with :truncation }
config.before(:each) { DatabaseCleaner.strategy = :transaction }
config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
config.before(:each) { DatabaseCleaner.start }
config.after(:each) { DatabaseCleaner.clean }
config.filter_rails_from_backtrace!
end
Ошибка возникает из-за
root_url пробовал просто вывести его значение, все равно получаю ошибку.
Подскажите в чем проблема?