thoughtbot/shoulda-context

MiniTest 5 compatibility

philnash opened this issue · 8 comments

With the recent release of Rails 4.1 beta1 I started to upgrade a Rails 4.0.2 app that uses shoulda for tests. Sadly this was not a smooth upgrade as ActiveSupport 4.1 requires minitest ~> 5.1.

In a small testcase initially shoulda context is unable to hook into MiniTest::Test so we start with undefined methodshould' for HelloWorldTest:Class`.

Including ShouldaContextLoadable into the test class stops that error, but no tests get run at all.

I would like to look into why this is happening, but I am not sure where to start. Can I get some guidance, please?

@philnash add this to Appraisals

appraise '4.1.0.beta1' do
  gem 'rails', github: 'rails/rails'
  gem 'jquery-rails'
  gem 'sass-rails', '4.0.1'
end

And only run rake. If got some problem try install appraisal by hand with bundle exec rake appraisal:install

@maurogeorge Thanks for the suggestion. I added that and the tests all passed. It still doesn't work though :(

@philnash yeah, I try this and all tests passed. Probably we need to write a new test, using your test case is a good idea.

@philnash Take a look at this line: https://github.com/thoughtbot/shoulda-context/blob/master/lib/shoulda/context.rb#L4. I am wondering if Minitest::Test needs to be present in this array. (Note that Minitest will not be available in MiniTest < 5 so we will need to check for its existence first)

Okay, guys, I came up with a fix for this. I had to do some refactoring of the current test framework detection code, and I also added some tests for this code as there were none before. Check out: #39.

I think this can be closed now.

yep, fixed in 1.2.0. thanks.

Awesome, thanks everyone!