0

我正在尝试开始第二个 Rails 项目,对于我的第一个项目,rspec 工作正常。我复制了 Gemfile 以获得相同的 gem,并且我的项目文件中有 spec/requests 目录。但是,当我尝试执行时出现此错误

C:\Sites\rails_projects\friendapp\app\views\static_pages>bundle exec rspec 规范/请求 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/ lib/rspec /core/configuration.rb:780:in load': cannot load such file -- C:/Sites/rails_pr ojects/friendapp/app/views/static_pages/spec/requests (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/configuration.rb:780:inblock in load_spec_files' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/ core/configuration.rb:780:in map' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/configuration.rb:780:inload_spec_files' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/command_line.rb: 22:in run' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/runner.rb:69:inrun' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/runner.rb:8:in `block in自动运行'

有什么线索吗?谢谢!

4

1 回答 1

1

看起来您不是从应用程序的根目录执行 bundle exec,而是从 app\views\static_pages 执行:

C:\Sites\rails_projects\friendapp\app\views\static_pages>

错误消息表明该位置不存在该文件(static_pages):

C:/Sites/rails_projects/friendapp/app/views/static_pages/spec/requests

更改到根目录并重试

C:\Sites\rails_projects\friendapp\>bundle exec rspec spec/requests 
于 2013-11-04T15:45:23.167 回答