1

我正在尝试安装 RSpec 以对我没有编写的应用程序进行一些测试。我已经放置

gem "rspec-rails", "~> 2.8"

在我的 gemfile 中并运行 bundle install。这工作得很好。直到我跑

rails 生成 rspec:install

我收到此错误:

/Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/whiny_nil.rb:48:in method_missing': undefined methodto_sym' for nil:NilClass (NoMethodError) from /Users/ anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1309:in action_path' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1304:in path_for_action' 来自 /Users/anthonyto/.rvm/gems/ruby -1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1159:in match' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1358:in match' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems /actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:394:in map_method' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:323:in get' from /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:447:in block (4 levels) in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:565:in block in controller' from /Users /anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:546: 在scope' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:565:in 控制器'来自 /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:446:in block (3 levels) in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:in block in namespace' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack- 3.0.20/lib/action_dispatch/routing/mapper.rb:546:in scope' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:in namespace' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/ routing/mapper.rb:1119:in namespace' from /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:406:in block (2 levels) in ' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper .rb:624:in block in namespace' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:546:in scope' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:624:in namespace' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/mapper.rb:1119:in namespace'来自 /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:405:in block in <top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:239:in instance_exec' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.20/lib/action_dispatch/routing/route_set.rb:239:in draw' from /Users/anthonyto/ActiveNetwork/active-trainer/config/routes.rb:1:in ' 来自 /Users/anthonyto/。 rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:in load' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:in block in load' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9。 3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in block in load_dependency' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in new_constants_in' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0。 20/lib/active_support/dependencies.rb:225:in load_dependency' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:236:in load' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb: 127: block in reload_routes!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:127:in 来自/Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:127: 在reload_routes!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:120:in 在 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/file_update_checker.rb:32:in call' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/file_update_checker.rb:32:in execute_if_updated' 中阻止 /Users/anthonyto/中的 routes_reloader' .rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:51:in block (2 levels) in <module:Finisher>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:52:in call' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9 .3-p194/gems/railties-3.0.20/lib/rails/application/finisher.rb:52:in block in <module:Finisher>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:25:in instance_exec' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties -3.0.20/lib/rails/initializable.rb:25:in run' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:50:in block in run_initializers' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails /initializable.rb:49:in each' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/initializable.rb:49:in run_initializers' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:134:in initialize!' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:77:in method_missing' 来自 /Users/anthonyto/ActiveNetwork/<top (required)>' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb 的active-trainer/config/environment.rb:5:in 要求: 242:in block in require' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in block in load_dependency' 来自 /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:597:in new_constants_in' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:225:in load_dependency' 来自 /Users /anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in require' from /Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/application.rb:103:in require_environment!来自/Users/anthonyto/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.0.20/lib/rails/commands.rb:16: <top (required)>' from script/rails:7:in需要'来自脚本/rails:7:in `'

我正在运行 ruby​​ 版本 1.9.3 和 rails 版本 3.0.20。我可以提供任何其他信息,任何帮助将不胜感激。谢谢你们!

编辑:当我尝试启动我的 Rails 服务器时,我遇到了同样的错误。似乎我的应用程序存在更深层次的问题。我以前当然没有这个问题,也想不出我所做的任何事情都会导致它。

4

1 回答 1

0

FIX:所以我弄清楚发生了什么,我会把它留在这里,让其他遇到这个烦人错误的人。原来我是个白痴,在 routes.rb 文件中留下了一些错误代码,如下所示:

  controller :calendar do
    get #write some routes here
  end

将其注释掉,一切正常。

于 2013-06-10T23:26:17.040 回答