minitest-rails 0.9 issue?

#29 · closed · 4 comments

View on GitHub ↗

tklenke

I am having trouble getting this to work with minitest 4.7.5, minitest-rails 0.9.2 and minitest-matchers 1.3.0, rails 3.2.15 If I replace for example MiniTest::Rails::ActiveSupport::TestCase with ActiveSupport::TestCase per https://github.com/blowmage/minitest-rails/wiki/Upgrading-to-0.9 Then I get a 'have_valid' method does not exist. Is this gem still supported? If not what is the new preferred method for testing attribute validation.

Comments

bcardarella

@tklenke could you put together an example app for me to work with? That will be this fixed the quickest

tklenke

Thank you for looking at this. https://github.com/tklenke/valid_attribute_test FYI, I use JRuby, so you may need to change the GEMFILE a bit. Perhaps JRuby is the issue, but should not be.

bcardarella

I apologize for taking a few days to get back to you. The state of Minitest with the migration from Minitest 4.x to Minitest 5.x has created some issues with what we can and cannot reasonably support in the same gem. To that end, there is a work around to get what you want: In your `tests/test_helper.rb` ``` ruby class ActiveSupport::TestCase include ::ValidAttribute::Method end ``` and in your unit test you will need to use `subject.wont` and `subject.must` ``` ruby it { subject.wont have_valid(:name).when(nil, '') } ```

tklenke

thank you. Works as advertised. Perhaps an update to the readme file is in order?