2

当我运行时:

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'

我遇到了与这篇文章中包含的错误类似的错误,但是提出的解决方案对我不起作用。

带有保护、rails 3.1.1 和 ruby​​ 1.9.3 的规范无法加载此类文件错误

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

任何有关情况的线索将不胜感激!

4

2 回答 2

4

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 
于 2012-04-18T11:32:46.963 回答
2

确保您正在bundle exec rspec spec/....从应用程序根目录执行命令。如果从子目录运行命令,则会收到此错误。

于 2012-04-23T05:21:22.000 回答