我在google和github上搜索了我在我的宝石上运行测试时收到的以下警告(请参阅下面的详细信息),全部通过:
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
我没有遇到任何问题的真正解决方案,并且警告并不清楚在哪里要求“minitest / autorun'或者为什么我需要添加' gen" minitest'"因为似乎activesupport-4.1.1.gem将其拉入(它位于我的vendors \ gems文件夹中)。有没有办法在运行我的测试时解决这个问题,因为当我运行测试时它只是一个警告:S
我的.gemspec文件......
# LittleWeasel pulls in activesupport-4.1.1...
spec.add_runtime_dependency 'LittleWeasel', '~> 2.1.2'
spec.add_runtime_dependency 'ProtectedConstructor', '~> 1.0.5'
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 2.13.0"
spec.add_development_dependency "yard", "0.8.6.2"
spec.add_development_dependency "redcarpet", "~> 2.3.0"
收到警告......
/Users/userabc/.rbenv/versions/1.9.3-p0/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/bin/rspec /Users/userabc/RubymineProjects/monkeyengine/test --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --pattern **/*_spec.rb
Testing started at 10:38 AM ...
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
**/Users/userabc/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit/assertions.rb:1:in `require'
/Users/userabc/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit/assertions.rb:1:in `<top (required)>'**
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyEngine/exceptions.rb:1:in `require'
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyEngine/exceptions.rb:1:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyAction/monkey_action_dead.rb:2:in `require'
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyAction/monkey_action_dead.rb:2:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyActions.rb:1:in `require_relative'
/Users/userabc/RubymineProjects/monkeyengine/lib/MonkeyActions.rb:1:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/lib/Monkey/monkey.rb:3:in `require'
/Users/userabc/RubymineProjects/monkeyengine/lib/Monkey/monkey.rb:3:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/lib/Monkey.rb:1:in `require_relative'
/Users/userabc/RubymineProjects/monkeyengine/lib/Monkey.rb:1:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/test/rspec/action_rules_spec.rb:3:in `require'
/Users/userabc/RubymineProjects/monkeyengine/test/rspec/action_rules_spec.rb:3:in `<top (required)>'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
/Users/userabc/RubymineProjects/monkeyengine/vendor/bundle/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
修改
top of action_rules_spec.rb文件:
require_relative 'spec_helpers'
require 'Monkey'
require 'MonkeyFactory'
require 'MonkeyEngine'
require 'MonkeyManager'
require 'MonkeyActions'
require_relative '../../lib/MonkeyKeyboard/keyboard_input'
describe 'ActionRules' do
...
spec_helpers.rb:
module SpecHelpers
module SetMonkeyAction
def set_action(action)
@action = action
end
end
end
答案 0 :(得分:2)
Minitest 5已将基本测试类API从Minitest::Test
更改为MiniTest 4中的MiniTest::Unit::TestCase
。它还将需求更改为minitest/test
minitest/unit
,尽管使用{{ 1}}会做正确的事。
ActiveSuport 4.0过去依赖于MiniTest 4,但ActiveSuport 4.1依赖于Minitest 5.
您的应用中有些内容需要minitest/autorun
。这看起来是RSpec版本2.13.1,已经超过一年了。尝试将RSpec升级到更新版本。