2
1

Rspecを実行するとin `<top (required)>': uninitialized constant NameErrorが発生する

Posted at

はじめに

すぐに解決できなかったのでまとめます

問題

Rspecを実行すると以下のエラーが出ました

rspec

Bullet settings loaded.
=== Bullet settings loaded. ===
[ddtrace] Unable to patch Datadog::Tracing::Contrib::ActionMailer::Integration (Available?: true, Loaded? true, Compatible? false, Patchable? false)
/apps/spec/controllers/api/internal/v1/dmappings_controller_spec.rb:4:in `<top (required)>': uninitialized constant Api::Internal::V1::MappingsController (NameError)
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
	from /usr/local/bundle/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

解決方法

コントローラーのファイル名が間違っていました

mappings.rb
↓
mappings_controller.rb

controllerをつけるのを忘れていました

おわりに

ファイル名間違えは地味に気づきにくいので最初にこころがけたほうがいいですね

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1