1

我正在尝试rails generate通过运行来生成集成测试

rails generate integration_test static_pages

但是,它没有调用 rspec 并在 spec/requests 目录中创建 static_pages_spec.rb ,而是向我显示了这个错误:

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:181:in `default_controller_and_action': 缺失:co
ntroller (ArgumentError)
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:78:in `normalize_options!'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:61:in `initialize'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1304:in `new'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1304:in `add_route'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1284:in `decomposed_match'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1270:in `block in match'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1270:in `each'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:1270:in `match'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:507:in `map_method'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/mapper.rb:469:in `get'
  来自 C:/Sites/rails_projects/sample_app/config/routes.rb:2:in `block in top (required)>'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.10/lib/action_dispatch/routing/route_set.rb:260:in `draw'
  来自 C:/Sites/rails_projects/sample_app/config/routes.rb:1:in `'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in `load'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in `block in load'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in `load_dependency'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in `load'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:40:in `each'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:40:in `load_paths'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:16:in `reload!'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:26:in `block in updater'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/file_update_checker.rb:78:in `call'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/file_update_checker.rb:78:in `execute'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application/routes_reloader.rb:27:in `updater'
  来自 C:in `execute_if_updated' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 0/lib/rails/application/finisher.rb:66:in `阻止'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `instance_exec'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:30:in `run'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:55:in `block in run_initializers'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `each'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/initializable.rb:54:in `run_initializers'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:136:in `initialize!'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/railtie/configurable.rb:30:in `method_missing'
  来自 C:/Sites/rails_projects/sample_app/config/environment.rb:5:in `'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/application.rb:103:in `require_environment!'
  来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.10/lib/rails/commands.rb:25:in `'
  来自脚本/rails:6:in `require'
  来自脚本/rails:6:in `'

我能做些什么来解决这个问题?

4

1 回答 1

1

我刚刚遇到了同样的问题。我输入root了我的 routes.rb 文件并忘记添加一个参数。如果我提出getpost没有任何论据,我会看到同样的事情发生。

请务必检查您的路线!

于 2013-01-24T04:17:47.680 回答