Ruby On Rails - 包含 gem 'minitest' 后 rspec 失败 [英] Ruby On Rails - rspec fails after include gem 'minitest'

查看:47
本文介绍了Ruby On Rails - 包含 gem 'minitest' 后 rspec 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我克隆了这个存储库:https://github.com/railstutorial/sample_app_rails_4

当我运行测试时出现错误并在这里找到答案:你应该需要'minitest/autorun'.在轨道上的红宝石

when I run the tests I got an error and found the answer here: you should require 'minitest/autorun' instead. in ruby on rails

但它引发了另一个错误:

But it throws another error which is:

No DRb server is running. Running in local process instead ...
/usr/lib/ruby/2.1.0/minitest/parallel_each.rb:67:in `<class:Unit>': undefined method `_run_suites' for class `Minitest::Unit' (NameError)

完整日志:

No DRb server is running. Running in local process instead ...
/usr/lib/ruby/2.1.0/minitest/parallel_each.rb:67:in `<class:Unit>': undefined method `_run_suites' for class `Minitest::Unit' (NameError)
    from /usr/lib/ruby/2.1.0/minitest/parallel_each.rb:66:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/testing/isolation.rb:2:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/test_case.rb:9:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/actionpack-4.0.8/lib/action_controller/test_case.rb:405:in `<module:ActionController>'
    from /var/lib/gems/2.1.0/gems/actionpack-4.0.8/lib/action_controller/test_case.rb:6:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/rspec-rails-2.13.1/lib/rspec/rails/example/controller_example_group.rb:9:in `<module:ControllerExampleGroup>'
    from /var/lib/gems/2.1.0/gems/rspec-rails-2.13.1/lib/rspec/rails/example/controller_example_group.rb:6:in `<module:Rails>'
    from /var/lib/gems/2.1.0/gems/rspec-rails-2.13.1/lib/rspec/rails/example/controller_example_group.rb:5:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/rspec-rails-2.13.1/lib/rspec/rails/example.rb:2:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/rspec-rails-2.13.1/lib/rspec/rails.rb:16:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `block in require'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /var/lib/gems/2.1.0/gems/activesupport-4.0.8/lib/active_support/dependencies.rb:229:in `require'
    from /home/dyego/Documents/coisas/rails/sample_app_rails_4/spec/spec_helper.rb:7:in `block in <top (required)>'
    from /var/lib/gems/2.1.0/gems/spork-1.0.0rc4/lib/spork.rb:24:in `prefork'
    from /home/dyego/Documents/coisas/rails/sample_app_rails_4/spec/spec_helper.rb:4:in `<top (required)>'
    from /home/dyego/Documents/coisas/rails/sample_app_rails_4/spec/controllers/relationships_controller_spec.rb:1:in `require'
    from /home/dyego/Documents/coisas/rails/sample_app_rails_4/spec/controllers/relationships_controller_spec.rb:1:in `<top (required)>'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:77:in `rescue in run'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:73:in `run'
    from /var/lib/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

它发生在我在 Gemfile 中包含 gem 'minitest' 并安装包之后.

It happens AFTER I included gem 'minitest' in my Gemfile and bundle install.

Rails 版本:Rails 4.0.8Ruby 版本:ruby 2.1.3p242 (2014-09-19 修订版 45877) [x86_64-linux-gnu]

Rails version: Rails 4.0.8 Ruby version: ruby 2.1.3p242 (2014-09-19 revision 45877) [x86_64-linux-gnu]

提前致谢

我被告知要指定 gem 的版本(minitest)

I was told to specify the version of the gem (minitest)

这是现在的样子:

宝石文件:

source 'https://rubygems.org'
ruby '2.1.3'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.8'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sprockets', '2.11.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'

group :development, :test do
  gem 'sqlite3', '1.3.8'
  gem 'rspec-rails', '2.13.1'
  # The following optional lines are part of the advanced setup.
  gem 'guard-rspec', '2.5.0'
  gem 'spork-rails', '4.0.0'
  gem 'guard-spork', '1.5.0'
  gem 'childprocess', '0.3.6'
end

group :test do
  gem "minitest", "~> 4.0"
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
  gem 'cucumber-rails', '1.3.0', :require => false
  gem 'database_cleaner', github: 'bmabey/database_cleaner'

  # Uncomment this line on OS X.
  gem 'growl', '1.0.3'

  # Uncomment these lines on Linux.
  # gem 'libnotify', '0.8.0'

  # Uncomment these lines on Windows.
  # gem 'rb-notifu', '0.0.4'
  # gem 'win32console', '1.3.2'
  # gem 'wdm', '0.1.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

捆绑安装日志:

bundle
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.42
Using activesupport 4.0.8
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.8
Using activemodel 4.0.8
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.8
Using bcrypt-ruby 3.1.2
Using sass 3.3.9
Using bootstrap-sass 2.3.2.0
Using will_paginate 3.0.4
Using bootstrap-will_paginate 0.0.9
Using mini_portile 0.6.0
Using nokogiri 1.6.2.1
Using xpath 2.0.0
Using capybara 2.1.0
Using timers 1.1.0
Using celluloid 0.15.2
Using ffi 1.9.3
Using childprocess 0.3.6
Using coderay 1.1.0
Using coffee-script-source 1.7.0
Using execjs 2.2.1
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.0.8
Using coffee-rails 4.0.1
Using diff-lcs 1.2.5
Using gherkin 2.12.2
Using multi_test 0.1.1
Using cucumber 1.3.15
Using cucumber-rails 1.3.0
Using database_cleaner 1.3.0 from git://github.com/bmabey/database_cleaner.git (at master)
Using factory_girl 4.2.0
Using factory_girl_rails 4.2.0
Using faker 1.1.2
Using formatador 0.2.5
Using growl 1.0.3
Using rb-fsevent 0.9.4
Using rb-inotify 0.9.5
Using listen 2.7.9
Using lumberjack 1.0.9
Using method_source 0.8.2
Using slop 3.5.0
Using pry 0.10.0
Using guard 2.6.1
Using rspec-core 2.13.1
Using rspec-expectations 2.13.0
Using rspec-mocks 2.13.1
Using rspec 2.13.0
Using guard-rspec 2.5.0
Using spork 1.0.0rc4
Using guard-spork 1.5.0
Using hike 1.2.3
Using jbuilder 1.0.2
Using jquery-rails 3.0.4
Using json 1.8.1
Using bundler 1.7.4
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.0.1
Using rails 4.0.8
Using rdoc 3.12.2
Using rspec-rails 2.13.1
Using rubyzip 0.9.9
Using sass-rails 4.0.1
Using sdoc 0.3.20
Using websocket 1.0.7
Using selenium-webdriver 2.35.1
Using spork-rails 4.0.0
Using sqlite3 1.3.8
Using turbolinks 1.1.1
Using uglifier 2.1.1
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

令我困惑的是,在我指定了 minitest 版本后,它仍然显示使用 minitest 4.7.5",我不完全确定为什么,我是 Rails 新手,也许我有一些愚蠢的事情我不知道.

What is confusing me is that after I specified the minitest version, it's still showing " Using minitest 4.7.5", and I'm not totally sure why, I'm new to Rails maybe there is something silly that I'm not aware of.

推荐答案

看起来 'test/unit'minitest 5 不兼容.

Looks like 'test/unit' and minitest 5 are not compatible.

尝试在 Gemfile 中明确指定版本 4

Try specifying version 4 explicitly in Gemfile

gem "minitest", "~> 4.0"

这篇关于Ruby On Rails - 包含 gem 'minitest' 后 rspec 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆