thoughtbot/shoulda — Issue #193: Using shoulda with Test::Unit AND RSpec
Author: iamvery
Created: 2011-11-17 14:58:25+00:00
State: open

Let me caveat this issue with a good old fashion: I've only recently run into this, so it may be a stupid question.

Until recently, I have been using Shoulda with `Test::Unit` for my testing on a particular project. I have finally gotten around to starting with RSpec to test a small extension I wrote for this project. I noticed as soon as I installed the RSpec gem, my Test::Unit tests are complaining about not having `context` and `should` methods. Naturally I took a peak at your code (v2.11.3)

Quickly noticed this:

if defined?(RSpec)
require 'shoulda/integrations/rspec2'
elsif defined?(Spec)
require 'shoulda/integrations/rspec'
else
require 'shoulda/integrations/test_unit'
end

This seems to be my problem right off the bat. Shoulda favors RSpec in terms of loading. I thought about it briefly and I couldn't determine why this would be the case. Are there not valid cases (mine in particular) where someone may want to use multiple testing frameworks on a single project? I feel like my Test::Unit tests are fine, and I am certainly not ready to invest the time it would take to convert all of them to RSpec.

I monkey-patched a fix by adding `require 'shoulda/integrations/test_unit'` to my `test_helper.rb` file...

Also, fyi, I took a peak at the v3beta stuff and the same problem seems to exist in the `shoulda-matcher` gem where it "integrates" with the frameworks.

I would love to hear your thoughts on this situation!