Rails测试失败

时间:2015-03-23 23:50:16

标签: ruby-on-rails testing rake rake-test

每当我运行以下代码时,我都会在终端上遇到这些错误。

rake test  or bundle exec rake test

/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- guard (LoadError)
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/guard-minitest-2.4.4/lib/minitest/guard_minitest_plugin.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:91:in `block in load_plugins'
from /usr/local/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:85:in `load_plugins'
from /usr/local/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:114:in `run'
from /usr/local/lib/ruby/gems/2.2.0/gems/minitest-5.5.1/lib/minitest.rb:56:in `block in autorun'

1 个答案:

答案 0 :(得分:1)

看起来Gemfile中没有安装/包含guard。如果它不存在,请将其包含在Gemfile中。并运行bundle install

有关如何使用警卫,请参阅http://railscasts.com/episodes/264-guardhttps://github.com/guard/guard也是一个很好的资源。