У меня есть эта запись в моих маршрутах файлRSpec говорит пользовательский путь не определен
namespace :api do
namespace :v1 do
get "/get_info/:pone/:ptwo", to: "whatever#getInfo", as: "get_info"
end
end
и это в моем файле спецификация
require 'rails_helper'
RSpec.describe "controller test", type: :request do
describe "get_info" do
it "gets info" do
get get_info_path(55,55)
expect(response).to have_http_status(200)
end
end
end
Когда я запускаю свой файл спецификация, он говорит undefined local variable or method 'get_info_path'
все ответы, которые я нашел до сих пор, говорят, что добавление config.include Rails.application.routes.url_helpers
в spec_helper.rb решит эту проблему, но это не решение моей проблемы
вот мой spec_helper:
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
RSpec.configure do |config|
config.include Rails.application.routes.url_helpers
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
config.shared_context_metadata_behavior = :apply_to_host_groups
end
и вот мой rails_helper:
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'
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.include ControllerSpecHelpers, :type => :controller
config.include FactoryGirl::Syntax::Methods
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!
config.filter_rails_from_backtrace!
end
Вы добавили 'config.include Rails.application.routes.url_helpers' в блок' RSpec.configure do | config | '? –
, который был бы положительным – Jarfis
Как выглядит ваш spec_helper.rb? –