metaskills / minitest-spec-rails

:bento: Make Rails Use MiniTest::Spec!

Home Page:http://github.com/metaskills/minitest-spec-rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ActiveSupport::TestCase used when testing module

stefankroes opened this issue · comments

Hi,

I'm using minitetest-spec-rails and I have a test case that tests some functionality on a module (some module methods). The gem registers ActiveSupport::TestCase as the base class for all class tests:

register_spec_type(self) { |desc| Class === desc }

For my use-case I would need this to be registered as the spec type for modules as well. Now it just uses the default Minitest::Spec. I fixed this by adding this to my test_helper.rb but I think you may want this to be default behavior.

MiniTest::Spec.register_spec_type(ActiveSupport::TestCase) { |desc| Module === desc }

Kind regards,

Stefan

Hey Stefan! Sorry for the late reply... been traveling.

So I take it you are using the "outer describe" syntax? If so, check out the test styles documentation we have on this topic. The change you mentioned is logical, but the goal of this gem is to only provide the Minitest::Spec DSL within the structure of Rails defaults.

Dear metaskills,

First off, sorry for not reading the clear documentation on this. I guess I've been mislead by the outer describe syntax working in most cases. Personally I would be sad to see this go but I guess it's best to remove it entirely if you don't want to support it.

Thank you for the explanation and thank you for a great gem.

Kind regards,

Stefan

Personally I would be sad to see this go

Hey Stefan. I would love to convince you to switch back to the standard way of subclassing that Rails tests endorse. I firmly believe it will lower the technical debt of your project too. The idea of this gem is to evaporate once Rails core allows the Minitest::Spec DSL within ActiveSupport::Test case. I believe that will happen and I am almost certain when they do, they will not endorse the outer describe syntax. So the idea is that one day, you will remove this gem from you Gemfile and everything should still work. Hope that helps and thanks!!!

Dear metaskills,

You've convinced me. I'm going to switch to the class based syntax. I like the outer describe syntax better visually but I have to admin that it's given me trouble at times.

Kind regards,

Stefan