"MiniTest framework was detected..." message after installing shoulda
I added shoulda gem to my Gemfile (which already has test-unit gem in Gemfile). Here is the relevant portion:
group :test do
gem 'mocha', :require => false
gem 'shoulda'
gem 'test-unit'
end
Just by doing that I get the following message:
---
MiniTest framework was detected. It is a lightweight version of original Test::Unit framework.
RubyMine/IDEA Ruby plugin test runner requires 'minitest-reporters' (>= 0.5.0) for integration
with MiniTest framework (see http://www.jetbrains.com/ruby/webhelp/minitest.html).
Or you can use full-featured Test::Unit framework version, provided by
'test-unit' gem, otherwise default console tests reporter will be used instead.
---
Why...and how can I get rid of this message (other than by not using shoulda)?
Please sign in to leave a comment.
The problem is that should does loads minitest when it is used with 1.9.
I think you can find the ticket about it in shoulda's issues.
For now you can ignore the message if your tests works fine in RM.
Oleg.
I don't see anything in shoulda's issues that indicates this is going to change.
The message is yours, and it's annoying.
Rather than making me choose between this annoying message in perpetuity, and running my tests on the command line, how about just making it so that I can make the message go away?
Here is the original issues in shoulda-matchers: https://github.com/thoughtbot/shoulda-matchers/issues/88
As far as I can see it was fixed with https://github.com/thoughtbot/shoulda-matchers/commit/c75c8334919772a8c09e6bcc8af4cdb8d0bc1d8f#lib/shoulda/matchers/assertion_error.rb
but very next change to the file has reverted changes :(
As for fixing: I see no way to detect that minitest will not be used when it is loaded :( If you know one please share with me.
Regards, Oleg.
I don't know why detecting that minitest would not be used is necessary.
As far as I can see everything is working. The only problem is the annoying message (you don't need to inform me of this condition 50 times per day).
You have a whole page where the user can configure messages. Maybe you can put a setting there to make this message go away.
This message still annoys the hell out of me. 50 times a day I see this ridiculous, pointless big red glob of nothing. Your software is full of messages. Most of them I can turn off. Why not this one? You have a big long message that prints in a context where you know it is not critical yet you know anyone who sees it is going to see it every time they run their tests. Do you think maybe ten times (or so) is enough?
Am I the only one around here that uses shoulda? Yea, I could do without shoulda if I had to. But I shouldn't have to make that tradeoff just because of an annoying message from an IDE that I paid a lot of money for.
I've filed pull request for shoulda-matcher (https://github.com/thoughtbot/shoulda-matchers/pull/181) but it has not been merged yet :(
If you want you could use this patch for your shoulda.
Regards, Oleg.
Thank you for following up.
Oleg,
Are you saying that if I apply this patch:
https://github.com/os97673/shoulda-matchers/commit/24e0e1d1d1c7ce44f4de6002b00a1a8486925b8b
manually to my shoulda-matcher gem the IDE message about "MiniTest framework was deteced...." will go away?
I have done so and I am still seeing the message.
Is there something else I need to do?
The patch does works only if you add
require 'test/unit'
before loading shoulda matchers
Oleg.
Please be more specific.
I reordered by Gemfile to put 'test-unit' before 'shoulda'. That did nothing.
I then tried putting :require => false after each one in the Gemfile, then added:
require 'test-unit'
require 'shoulda'
to my test_helper.rb.
That also made no difference.
Here is a test project which works for me (with modified should-matchers).
Does it works for you?
Can you provide a simple test project which demostrates the problem you have.
Regards, Oleg.
Attachment(s):
testunit-shoulda-spork-test.zip
I am attaching an app with the problem (including the .idea directory) and also the shoulda-matcher patched gem that I am using with it.
Attachment(s):
testapp.tar.gz
Hi Mark,
I've changed you Gemfile to not require shoulda and everything works fine.
Oleg.
Obviously it's fine because in that project none of the shoulda methods are called. The point of the exercise was to be able to use shoulda AND not see that message. I still have not accomplished that.
The point of me sending you that project was to show the message still being displayed with the patch applied.
Hi Mark,
indeed, the patch works only if test-unit is loaded before shoulda.
For the project you can just add "require 'shoulda'" to test_helper.rb after environment and rails are loaded
this way you will be able to use shoulda w/o seeing the warning.
Regards, Oleg.
I had already tried that.
This is my test_helper.rb:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'shoulda'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
--------------------------
and it gives me a cannot load such file error.
Here is my test_helper.rb:
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'shoulda'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
end
patched assertion_error.rb (from shoulda):
module Matchers
if Gem.ruby_version >= Gem::Version.new('1.8') && Gem.ruby_version < Gem::Version.new('1.9')
require 'test/unit'
AssertionError = Test::Unit::AssertionFailedError
elsif defined?(Test::Unit::AssertionFailedError)
# It looks like we already have what we need ;)
AssertionError = Test::Unit::AssertionFailedError
elsif Gem.ruby_version >= Gem::Version.new("1.9")
require 'minitest/unit'
AssertionError = MiniTest::Assertion
else
raise "No unit test library available"
end
end
end
And everything works :(
Testing started at 1:13 AM ...
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
Test suite finished: 0.194029659 seconds
Process finished with exit code 0
I got it to work finally but not with your example (which is essentially the same as my previous one).
If I put shoulda back in the Gemfile with :require => false it works (I had tried that before but by also doing the same with test-unit..and that didn't make the message go away).
Thanks
Great!!! I'm really happy that the problem has been resolved (at least for you ;))
Regards, Oleg.
Patch still not merged.
I keep updating and keep having to reapply this patch.
X-(
I'd suggest to ping shoulda-matchers' develepers about the patch (https://github.com/thoughtbot/shoulda-matchers/pull/181) It looks like they do not have free time to merge it :(
Oleg.
The pull request has been merged yesterday.
Oleg.
Very nice thank you.
This problem is back for me. :(
I am not sure what is happening because in a prior version of the same project (using the exact same Ruby) it is not happening. The versions of the shoulda* gems are also identical (also tried updating those to the latest but no change). Do you have a suggestion on what to look for (I am still including mocha, shoulda and test-unit in my Gemfile as above)?
Thanks
Hi Mark,
it is hard to say what is wrong now :(
I'd suggest to add debug output in our patcher which prints the message to see who and where loads minitest.
The file is <RM's directory>/rb/testing/patch/testunit/minitest/unit.rb
Hope this helps.
Regards, Oleg.