rspec rails 3.2.3和ruby 1.9.3无法加载此类文件错误

时间:2022-08-27 09:47:25

When I run:

当我运行:

bundle exec rspec spec/requests/static_pages_spec.rb:

包exec rspec规范/要求/ static_pages_spec.rb:

I get:

我得到:

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'

I'm getting a similar error to the one contained in this post, however the solution proposed doesn't work for me.

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

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

带有guard的spec、rails 3.1.1和ruby 1.9.3无法加载此类文件错误

I've run bundle install and rails generate rspec:install but the error remains. All the files are in their correct spots, and nothing has changed since last night, so I'm not sure what has happened.

我已经运行了bundle install, rails生成了rspec:install,但是错误仍然存在。所有的文件都在正确的位置上,从昨晚开始没有什么变化,所以我不确定发生了什么。

Any light shed on the situation would be greatly appreciated!

如能了解情况,将不胜感激!

2 个解决方案

#1


4  

It seems like rspec does not care that you stand in c:\sites\sample_app, as it tries to load

似乎rspec并不介意您站在c:\sites\sample_app中,因为它试图加载

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

Try to run rspec with an absolute path:

尝试运行rspec的绝对路径:

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

#2


2  

Make sure that you are executing the bundle exec rspec spec/.... command from the app root directory. If you run the command from a sub-directory, you will get this error.

确保你正在执行包exec rspec规范/ ....来自应用程序根目录的命令。如果从子目录运行命令,就会得到这个错误。

#1


4  

It seems like rspec does not care that you stand in c:\sites\sample_app, as it tries to load

似乎rspec并不介意您站在c:\sites\sample_app中,因为它试图加载

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

Try to run rspec with an absolute path:

尝试运行rspec的绝对路径:

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

#2


2  

Make sure that you are executing the bundle exec rspec spec/.... command from the app root directory. If you run the command from a sub-directory, you will get this error.

确保你正在执行包exec rspec规范/ ....来自应用程序根目录的命令。如果从子目录运行命令,就会得到这个错误。