機械音痴な情報系

そしてエンジニアに…。

RSpecでテストする際に、「Warning: you should require 'minitest/autorun' instead. Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'」と警告された。

RailsRSpecを使用してテストをした際に以下のような警告文に遭遇。 rubyは2.0.0p247、Railsは4.1.1を使用。

|| $ bundle exec rspec spec/requests/top_pages_spec.rb Warning: you should require 'minitest/autorun' instead. Warning: or add 'gem "minitest"' before 'require "minitest/autorun"' From: /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inblock in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in load_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/test/unit/assertions.rb:1:in <top (required)>' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in block in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:inload_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspec/rails/adapters.rb:3:in' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inblock in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in load_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspec/rails.rb:11:in <top (required)>' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in block in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:inload_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/WebApp/Fusion-Mania/spec/spec_helper.rb:4:in' /Users/Username/WebApp/Fusion-Mania/spec/requests/top_pages_spec.rb:1:in require' /Users/Username/WebApp/Fusion-Mania/spec/requests/top_pages_spec.rb:1:in' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in load' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inblock in load_spec_files' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in each' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inload_spec_files' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in run' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:inrun' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' .

Finished in 0.06401 seconds 1 example, 0 failures

Randomized with seed 58215 ||<

gemをインストールしてみる→全く同じ結果が出力される。

ぐぐったら対処法発見! ・2014-03-08 - nakaearthの日記

spec/spec_helper.rbに

|ruby| require 'minitest/autorun' ||< を追加。

|| $ bundle exec rspec spec/requests/top_pages_spec.rb Warning: you should require 'minitest/autorun' instead. Warning: or add 'gem "minitest"' before 'require "minitest/autorun"' From: /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inblock in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in load_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/test/unit/assertions.rb:1:in <top (required)>' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in block in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:inload_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspec/rails/adapters.rb:3:in' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inblock in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in load_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-rails-2.13.1/lib/rspec/rails.rb:11:in <top (required)>' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in block in require' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:inload_dependency' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in require' /Users/Username/WebApp/Fusion-Mania/spec/spec_helper.rb:4:in' /Users/Username/WebApp/Fusion-Mania/spec/requests/top_pages_spec.rb:1:in require' /Users/Username/WebApp/Fusion-Mania/spec/requests/top_pages_spec.rb:1:in' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in load' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inblock in load_spec_files' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in each' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:inload_spec_files' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in run' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:inrun' /Users/Username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun' .

Finished in 0.0549 seconds 1 example, 0 failures

Randomized with seed 53731

Run options: --seed 19447

Running:

Finished in 0.003810s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

||<

Running〜〜の出力が増えただけでまだ警告される…。

他にも発見。 ・Rails 4.0.4 から 4.1.0 に Update - 仙台 Ruby Vim JavaScript 自営業プログラマ

|ruby| gem "shoulda-matchers", "~> 2.6.0" ||< をGemfileに追加してbundle update , bundle install。

||

$ bundle exec rspec spec/requests/top_pages_spec.rb .

Finished in 0.11036 seconds 1 example, 0 failures

Randomized with seed 27883

Run options: --seed 23572

Running:

Finished in 0.005898s, 0.0000 runs/s, 0.0000 assertions/s.

0 runs, 0 assertions, 0 failures, 0 errors, 0 skips

||<

無事解決!