dyba
2010-May-30 02:08 UTC
[rspec-users] Adding custom directories in Rails app breaks RSpec testing
Hi: I''m trying to find out why is it when I change the Rails directory structure like so (app/controllers/physical/) does RSpec no longer work? I moved all my controller files to app/controllers/physical. Everything works fine when I run the server. But now I can''t test anymore: I get this message when I type the script/spec command: Paintdexter at R0M3 Sat May 29 19:05 >_ script/spec spec/controllers/ physical/home_controller_spec.rb /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:426:in `load_missing_constant'': Expected /Users/ Paintdexter/Ruby/atlas/app/controllers/physical/ application_controller.rb to define ApplicationController (LoadError) from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:92:in `const_missing'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:437:in `load_missing_constant'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:80:in `const_missing'' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ example/helper_example_group.rb:4 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require'' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ example.rb:9 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require'' from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails.rb: 17 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require'' from /Users/Paintdexter/Ruby/atlas/spec/spec_helper.rb:6 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:158:in `require'' from ./spec/controllers/physical/home_controller_spec.rb:1 from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:147:in `load_without_new_constant_marking'' from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ active_support/dependencies.rb:147:in `load'' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:15:in `load_files'' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:14:in `each'' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ example_group_runner.rb:14:in `load_files'' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ options.rb:133:in `run_examples'' from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ command_line.rb:9:in `run'' from script/spec:10 Paintdexter at R0M3 Sat May 29 19:06 >_ I made sure to add the custom directories in the config/environment.rb file: ## # Adding load paths for my custom directories ## config.load_paths += %W( #{RAILS_ROOT}/app/models/logical #{RAILS_ROOT}/app/controllers/physical #{RAILS_ROOT}/app/controllers/service #{RAILS_ROOT}/app/views/physical #{RAILS_ROOT}/spec/controllers/physical #{RAILS_ROOT}/spec/views/physical ) This however doesn''t work. How can I make RSpec aware that the Rails app directory structure has changed?
David Chelimsky
2010-Jun-09 12:47 UTC
[rspec-users] Adding custom directories in Rails app breaks RSpec testing
On Sat, May 29, 2010 at 10:08 PM, dyba <dyba.ruby at gmail.com> wrote:> Hi: > > I''m trying to find out why is it when I change the Rails directory > structure like so (app/controllers/physical/) does RSpec no longer > work? I moved all my controller files to app/controllers/physical. > Everything works fine when I run the server. But now I can''t test > anymore: I get this message when I type the script/spec command: > > Paintdexter at R0M3 Sat May 29 19:05 >_ script/spec spec/controllers/ > physical/home_controller_spec.rb > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/ > dependencies.rb:426:in `load_missing_constant'': Expected /Users/ > Paintdexter/Ruby/atlas/app/controllers/physical/ > application_controller.rb to define ApplicationController (LoadError)This is the error right here ^^ though it is missing an important bit of info: app/controllers/physical/application_controller.rb should define Physical::ApplicationController> ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:92:in `const_missing'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:437:in `load_missing_constant'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:80:in `const_missing'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ > example/helper_example_group.rb:4 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails/ > example.rb:9 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-rails-1.3.2/lib/spec/rails.rb: > 17 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require'' > ? ? ? ?from /Users/Paintdexter/Ruby/atlas/spec/spec_helper.rb:6 > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `gem_original_require'' > ? ? ? ?from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in > `require'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:158:in `require'' > ? ? ? ?from ./spec/controllers/physical/home_controller_spec.rb:1 > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:147:in > `load_without_new_constant_marking'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/ > active_support/dependencies.rb:147:in `load'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:15:in `load_files'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:14:in `each'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > example_group_runner.rb:14:in `load_files'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > options.rb:133:in `run_examples'' > ? ? ? ?from /Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/ > command_line.rb:9:in `run'' > ? ? ? ?from script/spec:10 > Paintdexter at R0M3 Sat May 29 19:06 >_ > > I made sure to add the custom directories in the config/environment.rb > file: > > ?## > ?# Adding load paths for my custom directories > ## > config.load_paths += %W( > #{RAILS_ROOT}/app/models/logical > #{RAILS_ROOT}/app/controllers/physical > #{RAILS_ROOT}/app/controllers/service > #{RAILS_ROOT}/app/views/physical > #{RAILS_ROOT}/spec/controllers/physical > #{RAILS_ROOT}/spec/views/physical > ) > > This however doesn''t work. How can I make RSpec aware that the Rails > app directory structure has changed?