无法执行bundle exec rspec spec / requests / static_pages_spec.rb

时间:2014-01-11 18:44:45

标签: ruby-on-rails ruby rspec ruby-on-rails-4

我正在遵循迈克尔·哈特尔的示例Ruby on Rails教程,但我陷入困境。

每当我尝试运行以下测试时,我都会遇到一个巨大的错误

  

$ bundle exec rspec spec / requests / static_pages_spec.rb

No DRb server is running. Running in local process instead ...
/home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file -- /home/almeidamarcell/rails_projects/sample_app/spec/requests/static_pages_spec.rb (LoadError)
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:77:in `rescue in run'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:73:in `run'
    from /home/almeidamarcell/.rvm/gems/ruby-2.1.0@railstutorial_rails_4_0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

我已尝试过在stackoverflow和Google上找到的所有解决方案。我现在不知道该怎么做。我知道测试它非常重要,我想解决这个问题。 另外,我在“/requests/static_pages_spec.rb”目录下什么都没有,也许这就是问题所在?如果是的话,我必须在那里创造什么?我甚至没有创建请求目录。

本教程没有说明创建此文件夹的内容,因此我认为应该自动创建rails规范?

的Gemfile http://pastebin.com/4bvy7GrW

spec_helper http://pastebin.com/F9yJTFqv

2 个答案:

答案 0 :(得分:1)

'spec'文件夹中应该有'requests'文件夹。在这个'requests'文件夹中你应该有你的文件'static_pages_spec.rb'。该教程没有说明创建此文件夹的任何内容可能是代表作者的一个小疏忽。

答案 1 :(得分:1)

我不确定您是否发布了错误的链接,但是您对static_pages_spec.rb的代码 应该位于spec / spec_helper.rb文件中。静态页面的请求规范具有以下格式

require 'spec_helper'

describe "Static pages" do
   #Insert More describe blocks and Tests here
 end

当然,如果没有创建文件夹,您应该手动创建并相应地命名