0

我正在尝试将我的 Rails 应用程序从 ubuntu 移动到 osx。运行 rspec 时,出现以下模糊错误:

/Users/josh/dev/myproject/spec/support/devise.rb:3:in `block in <top (required)>': uninitialized constant RequestHelpers (NameError)
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core.rb:92:in `configure'
    from /Users/josh/dev/myproject/spec/support/devise.rb:1:in `<top (required)>'
    from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `block (2 levels) in <top (required)>'
    from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `each'
    from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `block in <top (required)>'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
    from /Users/josh/dev/myproject/spec/spec_helper.rb:4:in `<top (required)>'
    from /Users/josh/dev/myproject/spec/controllers/comments_controller_spec.rb:1:in `require'
    from /Users/josh/dev/myproject/spec/controllers/comments_controller_spec.rb:1:in `<top (required)>'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `rescue in run'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in `run'
    from /Users/josh/.rvm/gems/ruby-1.9.3-p286@myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

一切都在 Ubuntu 中运行良好,所以我想它一定是环境的。任何想法从哪里开始挖掘?

谢谢 - 乔什

编辑:不知道为什么,但是 rake 找不到文件 request_helpers.rb。把它移到别处解决了这个问题。

4

1 回答 1

1

这似乎不是操作系统问题,而是配置问题。确保您的环境在以下方面是相同的:

  • 使用 rvm 安装方式相同
  • 在 Gemfile 中拥有所有需要的宝石
  • 使用 bundle 执行 rspec
  • 使用相同版本的所有内容。

顺便说一句,这不是一条晦涩难懂的信息,实际上很清楚:

uninitialized constant RequestHelpers (NameError)

所以spec/support/devise.rb文件找不到所需的类。

你写过那个文件吗?如果没有,您是如何生成的?重复该过程以生成它(可能是rake somethingrails generate something),它就可以了。

于 2012-11-06T10:53:52.273 回答