lib/test_dummy/railtie.rb in test_dummy-0.4.0 vs lib/test_dummy/railtie.rb in test_dummy-0.5.0
- old
+ new
@@ -1,6 +1,6 @@
-require File.expand_path('../test_dummy', File.dirname(__FILE__))
+require_relative '../test_dummy'
case (Rails::VERSION::MAJOR)
when 2
if (defined?(ActiveRecord) and defined?(ActiveRecord::Base))
ActiveRecord::Base.send(:include, TestDummy)
@@ -12,18 +12,27 @@
Test::Unit::TestCase.send(:include, TestDummy::TestHelper)
end
else
class TestDummy::Railtie < Rails::Railtie
def self.apply!
- if (defined?(ActiveRecord))
+ if (defined?(ActiveRecord) and defined?(ActiveRecord::Base))
ActiveRecord::Base.send(:include, TestDummy)
end
- ActiveSupport::TestCase.send(:include, TestDummy::TestHelper)
- Test::Unit::TestCase.send(:include, TestDummy::TestHelper)
+ if (defined?(ActiveSupport) and defined?(ActiveSupport::TestCase))
+ ActiveSupport::TestCase.send(:include, TestDummy::TestHelper)
+ end
+
+ if (defined?(Test) and defined?(Test::Unit))
+ Test::Unit::TestCase.send(:include, TestDummy::TestHelper)
+ end
+
+ if (defined?(MiniTest) and defined?(MiniTest::Unit))
+ MiniTest::Unit::TestCase.send(:include, TestDummy::TestHelper)
+ end
end
- config.before_configuration do
- apply!
+ config.to_prepare do
+ TestDummy::Railtie.apply!
end
end
end