thoughtbot/shoulda

Setup/teardown not being called after upgrading shoulda.

tiegz opened this issue · 5 comments

Hello, I just upgraded the following gem in a Rails app:

  • Rails 3.0.12 -> 3.2.2
  • Shoulda 2.11.3 -> 3.0.1 (& added the shoulda-context gem)
  • FactoryGirl -> 2.60 and FactoryGirlRails to 1.7.0

I noticed from a failing test that the contexts' transactions for each test weren't being rolled back in the test database. From there I realized that even though the setup :setup_fixtures and teardown :teardown_fixtures callbacks were being added from ActiveRecord::TestFixtures module, the callback chains themselves (:setup and :teardown) weren't actually being run.

I'm still looking into this, but I just wanted to make sure I didn't miss some change, and that this is intentional? Thanks!

Note: I've also kept these settings in the test_helper.rb:

class ActiveSupport::TestCase
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false
end

Hi,

I'm a little confused - where are these callbacks added? Is it in shoulda-context or shoulda-matchers?

Thanks,
-- Gabe

@tiegz, can you show an example in code of what you're talking about?

Argh, I knew once I posted an issue I'd figure this out 😳

It turns out this specific unit test I was running inherited from Test::Unit::TestCase instead of ActiveSupport::TestCase. I'm waiting for my gems to reinstall before I can double-check that the rollback transactions are occurring, but I'll assume this fixed it.

Thanks guys, sorry for the false alarm!

I'm glad you fixed it!