我正在通过Michael Hartl的《Ruby on Rails教程》学习RoR。
现在我尝试使用Guard运行测试。
我的Gemfile文件:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.2'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.5.0'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'libnotify', '0.8.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
我的 Guard 文件:
require 'active_support/inflector'
guard 'rspec', all_after_pass: false do
watch('config/routes.rb')
# Custom Rails Tutorial specs
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
["spec/routing/#{m[1]}_routing_spec.rb",
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
"spec/acceptance/#{m[1]}_spec.rb",
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
"spec/requests/#{m[1].singularize}_pages_spec.rb")]
end
watch(%r{^app/views/(.+)/}) do |m|
(m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
"spec/requests/#{m[1].singularize}_pages_spec.rb")
end
watch(%r{^app/controllers/sessions_controller\.rb$}) do |m|
"spec/requests/authentication_pages_spec.rb"
end
end
当我尝试运行 guard(或 bundle exec guard)时,我收到以下错误:
gvyntyk@gvyntyk-r60:~/rails_projects/sample_app$ guard
14:31:28 - INFO - Guard here! It looks like your project has a Gemfile, yet you are running
> [#] `guard` outside of Bundler. If this is your intent, feel free to ignore this
> [#] message. Otherwise, consider using `bundle exec guard` to ensure your
> [#] dependencies are loaded correctly.
> [#] (You can run `guard` with --no-bundler-warning to get rid of this message.)
14:31:29 - ERROR - Could not load 'guard/rspec' or' ' find class Guard::Rspec
14:31:29 - ERROR - Error is: cannot load such file -- guard/guard
14:31:29 - ERROR - /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
> [#] /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:126:in `require'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-rspec-2.5.0/lib/guard/rspec.rb:2:in `<top (required)>'
> [#] /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
> [#] /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
> [#] /home/gvyntyk/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/plugin_util.rb:105:in `rescue in plugin_class'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/plugin_util.rb:97:in `plugin_class'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/plugin_util.rb:56:in `initialize_plugin'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/internals/plugins.rb:26:in `add'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/dsl.rb:185:in `block in guard'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/dsl.rb:182:in `each'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/dsl.rb:182:in `guard'
> [#] /home/gvyntyk/rails_projects/sample_app/Guardfile:3:in `evaluate'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/dsl.rb:377:in `instance_eval'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/dsl.rb:377:in `evaluate'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/guardfile/evaluator.rb:90:in `evaluate'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard.rb:134:in `_evaluate'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard.rb:49:in `setup'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/commander.rb:32:in `start'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/cli.rb:113:in `start'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/aruba_adapter.rb:32:in `execute'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/gems/guard-2.11.1/bin/guard:11:in `<top (required)>'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/bin/guard:23:in `load'
> [#] /home/gvyntyk/.rvm/gems/ruby-2.0.0-p598@railstutorial_rails_4_0/bin/guard:23:in `<main>'
14:31:29 - ERROR - Invalid Guardfile, original error is:
> [#]
> [#] Could not load class: "Rspec",
> [#] backtrace:
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/plugin_util.rb:57:in `initialize_plugin'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/internals/plugins.rb:26:in `add'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/dsl.rb:185:in `block in guard'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/dsl.rb:182:in `each'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/dsl.rb:182:in `guard'
> [#] (dsl)> ./Guardfile:3:in `evaluate'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/dsl.rb:377:in `instance_eval'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/dsl.rb:377:in `evaluate'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/guardfile/evaluator.rb:90:in `evaluate'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard.rb:134:in `_evaluate'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard.rb:49:in `setup'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/commander.rb:32:in `start'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/cli.rb:113:in `start'
> [#] (dsl)> $GEM_PATH[0]/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#] (dsl)> $GEM_PATH[0]/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#] (dsl)> $GEM_PATH[0]/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#] (dsl)> $GEM_PATH[0]/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/aruba_adapter.rb:32:in `execute'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#] (dsl)> $GEM_PATH[0]/gems/guard-2.11.1/bin/guard:11:in `<top (required)>'
> [#] (dsl)> $GEM_PATH[0]/bin/guard:23:in `load'
> [#] (dsl)> $GEM_PATH[0]/bin/guard:23:in `<main>'
< p > 顺便说一句:< /p >gem list | grep guard
guard (2.11.1)
guard-compat (1.2.1)
guard-rspec (2.5.0)
有什么问题吗?