无法运行rake测试Rails

时间:2016-05-11 03:00:20

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

我正在关注Michael Hartl的Rails教程(chapter 3)。但是,当我像他一样编辑 Gemfile 然后运行rake测试时,rails建议我放置这一行:config.web_console.development_only = false应用程序配置文件中。我这样做并再次运行bundle exec rake test,这是错误消息:

/home/ys/workspace/sample_app/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ys/workspace/sample_app/config/application.rb to limit the frameworks that will be loaded.
/home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- guard (LoadError)
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/guard-minitest-2.4.4/lib/minitest/guard_minitest_plugin.rb:4:in `<top (required)>'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:91:in `block in load_plugins'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:85:in `each'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:85:in `load_plugins'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:114:in `run'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:56:in `block in autorun'

然后我继续rake db:migrate,然后再次进行rake测试:

Running via Spring preloader in process 15638
/home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- guard (LoadError)
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/guard-minitest-2.4.4/lib/minitest/guard_minitest_plugin.rb:4:in `<top (required)>'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:91:in `block in load_plugins'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:85:in `each'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:85:in `load_plugins'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:114:in `run'
    from /home/ys/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/minitest-5.8.4/lib/minitest.rb:56:in `block in autorun'

所有我能猜到的是Ruby出了问题,因为前几天当我运行bundle install时,rails控制台抱怨了bug,旧版本,因此我从2.3.0升级到2.3.1。 那么,如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

看起来这可能有效:

  

1)只需从Gemfile和Guardfile中删除guard-spring即可。

     

2)然后升级guard-rspec(运行包更新guard-rspec)

     

3)设置   guard-rspec使用spring(见:   https://github.com/guard/guard-rspec#options

来自:https://github.com/guard/guard/issues/734

答案 1 :(得分:1)

https://github.com/guard/guard-minitest

将gem gem添加到您的gem文件中 宝石&#39;后卫&#39;