【问题标题】:rspec rails 3.2.3, and ruby 1.9.3 getting cannot load such file errorsrspec rails 3.2.3, and ruby​​ 1.9.3 getting cannot load such file 错误
【发布时间】:2014-04-24 17:35:21
【问题描述】:

当我跑步时:

bundle exec rspec spec/requests/static_pages_spec.rb:

我明白了:

c:\Sites\sample_app>bundle exec rspec spec/requests/static_pages_spec.rb
C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/conf
iguration.rb:746:in `load': cannot load such file -- c:/Sites/spec/requests/stat
ic_pages_spec.rb (LoadError)
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
    from C:/Rails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

我遇到了与本文中包含的错误类似的错误,但是建议的解决方案对我不起作用。

spec with guard, rails 3.1.1, and ruby 1.9.3 getting cannot load such file errors

我已经运行了bundle installrails generate rspec:install,但错误仍然存​​在。所有文件都在正确的位置,自昨晚以来没有任何变化,所以我不确定发生了什么。

我们将不胜感激!

【问题讨论】:

    标签: ruby-on-rails ruby rspec2


    【解决方案1】:

    rspec 似乎并不关心你是否站在 c:\sites\sample_app 中,因为它会尝试加载

    c:/Sites/spec/requests/static_pages_spec.rb 
    

    尝试使用绝对路径运行 rspec:

     bundle exec rspec c:/Sites/sample_app/spec/requests/static_pages_spec.rb 
    

    【讨论】:

    • 就是这样,你就是传奇。之所以会发生这种情况,是因为今天早些时候我跳进了 regedit 为命令提示添加了一个自动运行,以便在 c:\Sites 中启动我,而不是每次打开命令提示时都必须导航到它。我不知道它会影响这个。我解开了它,它工作得很好。再次感谢。
    • 必须从 sample_app 文件夹运行“bundle exec spec/requests/static_pages_spec.rb”命令。我试图在更深的目录中运行它,但在我想备份到 sample_app 之前它没有工作。
    【解决方案2】:

    确保您从应用根目录执行bundle exec rspec spec/.... 命令。如果你从子目录运行命令,你会得到这个错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-25
      • 2021-03-03
      相关资源
      最近更新 更多