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'
내가 찾은 모든 답변은 spec_helper.rb에 config.include Rails.application.routes.url_helpers
을 추가하면이 문제가 해결되지만 내 문제는 해결되지 않는다고 말합니다.
내 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 : 당신이 $ rake routes
을 실행하면
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는 어떻게 생겼습니까? –