【发布时间】:2015-08-16 08:15:44
【问题描述】:
我正在关注 Michael Hartl 的 Ruby on Rails 示例教程,但我卡住了。
每次我尝试运行以下测试时都会出错:
time rspec spec/requests/static_pages_spec.rb
我的错误:
/home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load': cannot load such file -- /home/i/rails_projects/sample_app/spec/spec/requests/static_pages_spec.rb (LoadError)
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:88:in `run'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:73:in `run'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:41:in `invoke'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/rspec-core-3.3.2/exe/rspec:4:in `<top (required)>'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/bin/rspec:23:in `load'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/bin/rspec:23:in `<main>'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `eval'
from /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/bin/ruby_executable_hooks:15:in `<main>'
real 0m0.752s
user 0m0.699s
sys 0m0.044s
static_pages_spec.rb:
require 'spec_helper'
describe "StaticPages" do
describe "Home page" do
it "It should have the content 'Sample App'" do
visit '/static_pages/home'
expect(page).to have_content('Sample App')
end
it "should have the right title" do
visit '/static_pages/home'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Home")
end
end
describe "Help page" do
it "It should have the content 'Help'" do
visit '/static_pages/help'
expect(page).to have_content('Help')
end
it "should have the right title" do
visit '/static_pages/help'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Help")
end
end
describe "About page" do
it "It should have the content 'About Us'" do
visit '/static_pages/about'
expect(page).to have_content('About Us')
end
end
it "should have the right title" do
visit '/static_pages/about'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | About Us")
end
describe "Contact" do
it "It should have the content 'Contact'" do
visit '/static_pages/contact'
expect(page).to have_content('Contact')
end
end
it "should have the right title" do
visit '/static_pages/contact'
expect(page).to have_title("Ruby on Rails Tutorial Sample App | Contact")
end
end
Gemfile: ## http://pastebin.com/1RhbaCiK
操作系统:Ubuntu 14.04
我一直在寻找解决方案,但没有找到。请记住,我是 Ruby on Rails 和 Web 开发的新手。
【问题讨论】:
-
请出示
spec_helper.rb -
是的,总是从那里
-
我试图解决这个问题,但又得到了一个。现在,如果我运行该命令,我会得到: :~/rails_projects/sample_app$ time rspec spec/requests/static_pages_spec.rb /home/i/.rvm/gems/ruby-2.0.0-p643@railstutorial_rails_4_0/gems/guard- spork-1.5.0/lib/guard/spork.rb:2:in `require': 无法加载这样的文件 --guard/guard (LoadError)
-
下面答案中的解决方案。在 Gemfile 和 Gemfile.lock 中更新 gem 'guard-spork' - 从 '1.5.0' 到 '2.1.0'
标签: ruby-on-rails ruby-on-rails-4 rspec