Rails:为什么RSpec会崩溃我的被覆盖的Devise控制器请求规范?

更新:哦,好悲伤,这是一个糟糕的合并后的红鲱鱼。 沿着这条线的某个地方,以下内容从spec / spechelper.rb的清理中删除

Dir["#{Rails.root}/app/**/*.rb"].each {|f| load f} 

现在这已经恢复,一切都在恢复。 我怀疑它只是加载平面目录,而不是嵌套目录,使它看起来像命名空间问题。

(我不能回答我自己的问题,因为这是一个新帐户,我没有代表)


原始问题:

我的大多数RSpec / Capybara测试工作正常,但我有一个测试只是试图访问路径爆炸,我坚持调试。 我怀疑这是一个命名空间问题,但我不知道如何解决这个问题; 任何帮助感激不尽。

整个测试是:

 require 'spec_helper' describe 'Registrations' do context 'when debugging the blocking issue' do it 'this minimal test should pass' do visit new_user_registration_path end end end 

错误消息是:

$ bin / rspec spec / requests / users / registrations_spec.rb

失败:

1)用户::调试阻塞问题时的注册这个最小测试应该通过失败/错误:访问new_user_registration_path LoadError:预期的app / controllers / users / registrations_controller.rb来定义Users :: RegistrationsController#。/ spec / recall / users / registrations_spec .rb:10:在`block(3 levels)in’

所以错误是Expected users / registrations_controller.rb来定义Users :: RegistrationsController ,这没什么用处!

控制器是一个重写的Devise控制器,它看起来像:

 class Users::RegistrationsController < Devise::RegistrationsController def create super # My extra code here end end 

我的路线重定向设计了一点:

 devise_for :users, :controllers => { :registrations => 'users/registrations' } do get '/users/sign_out' => 'devise/sessions#destroy' end 

我完全坚持试图找到’预期的foo.rb来定义Foo’错误的根本原因’; 我无法深入了解导致我的问题的原因。

你接下来要做什么调试呢?


大卫建议回溯可能会有所帮助; 据我所知,我没有阻止加载的错误,看起来对我(但我是一个rails noob)像所有ActiveSupport块一样。 这是感兴趣的:

   1)Users ::调试阻塞问题时的注册,这个最小测试应该通过
     失败/错误:访问new_user_registration_path

      LoadError:
       期望的app / controllers / users / registrations_controller.rb定义Users :: RegistrationsController
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:490:在`load_missing_constant'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:181:在`const inmissing'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:179:in“each”
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:179:在`const_missing'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / inflector / methods.rb:124:在'constantize中的块'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / inflector / methods.rb:123:in“each”
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / inflector / methods.rb:123:in`constantize'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:528:在`block in initialize'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:550:在`yield'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:550:在`default'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / dependencies.rb:550:in`[]'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / routing / route_set.rb:61:在`controller_reference'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / routing / route_set.rb:46:in`controller'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / routing / route_set.rb:25:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / routing / mapper.rb:41:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-mount-0.8.3 / lib / rack / mount / route_set.rb:152:在`block in call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-mount-0.8.3 / lib / rack / mount / code_generation.rb:96:,,,,,,,,,
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-mount-0.8.3 / lib / rack / mount / code_generation.rb:110:在`optimized_each'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-mount-0.8.3 / lib / rack / mount / code_generation.rb:95:在`识别'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-mount-0.8.3 / lib / rack / mount / route_set.rb:141:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / routing / route_set.rb:531:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / sass-3.1.12 / lib / sass / plugin / rack.rb:54:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / warden-1.1.0 / lib / warden / manager.rb:35:in"clock in call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / warden-1.1.0 / lib / warden / manager.rb:34:in,get'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / warden-1.1.0 / lib / warden / manager.rb:34:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / best_standards_support.rb:17:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / etag.rb:23:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / conditionalget.rb:25:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / head.rb:14:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / params_parser.rb:21:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / flash.rb:243:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / session / abstract / id.rb:195:in`context'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / session / abstract / id.rb:190:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / cookies.rb:326:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activerecord-3.1.0 / lib / active_record / query_cache.rb:62:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activerecord-3.1.0 / lib / active_record / connection_adapters / abstract / connection_pool.rb:477:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / callbacks.rb:29:in block in call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / callbacks.rb:392:in`_run_call_callbacks'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / callbacks.rb:81:在`run_callbacks'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / callbacks.rb:28:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / sendfile.rb:101:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / remote_ip.rb:48:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / show_exceptions.rb:47:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / railties-3.1.0 / lib / rails / rack / logger.rb:13:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / methodoverride.rb:24:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / runtime.rb:17:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / activesupport-3.1.0 / lib / active_support / cache / strategy / local_cache.rb:72:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / lock.rb:15:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / actionpack-3.1.0 / lib / action_dispatch / middleware / static.rb:53:in`call'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / railties-3.1.0 / lib / rails / engine.rb:455:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / urlmap.rb:52:在`block in call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / urlmap.rb:46:in“each”
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-1.3.5 / lib / rack / urlmap.rb:46:在`call'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-test-0.6.1 / lib / rack / mock_session.rb:30:in“request”
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-test-0.6.1 / lib / rack / test.rb:219:在`process_request'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rack-test-0.6.1 / lib / rack / test.rb:57:in"get“
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / capybara-1.1.2 / lib / capybara / rack_test / browser.rb:62:in"process'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / capybara-1.1.2 / lib / capybara / rack_test / browser.rb:21:in`visit'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / capybara-1.1.2 / lib / capybara / rack_test / driver.rb:32:in`visit'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / capybara-1.1.2 / lib / capybara / session.rb:157:在`visit'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / capybara-1.1.2 / lib / capybara / dsl.rb:161:在`visit'
      #./spec/requests/users/registrations_spec.rb:10:in`block(3 levels)in'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example.rb:51:in`instance_eval'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example.rb:51:in"block in run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example.rb:110:in`with_around_hooks'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example.rb:48:in"run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:306:在`block in run_examples'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:302:in`map'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:302:在`run_examples'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:274:in"run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:275:在`block in run'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:275:in`map'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / example_group.rb:275:在`run'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / command_line.rb:24:in"block(2 level)in run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / command_line.rb:24:in"map'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / command_line.rb:24:in"block in run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / reporter.rb:12:在`report'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / command_line.rb:21:in"run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / runner.rb:80:在`run_in_process'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / runner.rb:66:在`rescue in run'中
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / runner.rb:62:in"run'
      #.rvm / gems / ruby​​-1.9.3-p0 @ foo / gems / rspec-core-2.7.1 / lib / rspec / core / runner.rb:10:在`block in autorun'中

如果输入bin/rspec --help ,您将看到可以添加到命令的选项和开关列表,包括--backtrace开关,它告诉RSpec显示完整的回溯。 如果运行bin/rspec spec/requests/users/registrations_spec.rb --backtrace您应该准确地看到错误的来源。

HTH,大卫

更新:哦,好悲伤,这是一个糟糕的合并后的红鲱鱼。 沿着这条线的某个地方,以下内容从spec / spechelper.rb的清理中删除

 Dir["#{Rails.root}/app/**/*.rb"].each {|f| load f} 

现在这已经恢复,一切都在恢复。 我怀疑它只是加载平面目录,而不是嵌套目录,使它看起来像命名空间问题。