Я поставил код в спецификации/поддержка/request_helpers.rbнеинициализированные постоянные запросы (NameError)
module Requests
module JsonHelpers
def json
@json ||= JSON.parse(response.body)
end
end
end
Затем я добавил строку конфигурации спецификации/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'
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.include Requests::JsonHelpers, :type => :controller
end
Так что, когда я запускаю мои спецификации от спецификации/контроллера/tasks_controller_spec.rb я получаю следующее сообщение об ошибке.
/spec/rails_helper.rb:16:in `block in <top (required)>': uninitialized constant Requests (NameError)
Как это решить?
У меня есть require 'rails_helper'
наверху.
Спасибо, ЗЕЛЕНЫЙ;) –