public
Rubygem
Description: RSpec extension library for Ruby on Rails
Homepage:
Clone URL: git://github.com/dchelimsky/rspec-rails.git
Call Rail's TestCase setup/teardown callbacks

Rails r8664 introducted ActiveSupport::Callbacks into TestCase, used for loading 
fixtures, among other things.
Ensure they're called when rspec runs vanilla TestCase tests.

Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv>
Jonathan del Strother (author)
Fri Jul 11 15:48:27 -0700 2008
David Chelimsky (committer)
Thu Jul 17 16:50:00 -0700 2008
commit  5d62ea0ed9a4f7c5cba81048ef2af998a5348148
tree    49b2bf243924573d62f59a692c302cb160751ca0
parent  557a2cef32895bd4b3ca5c5da0d41dba0f02c849
...
12
13
14
 
15
...
12
13
14
15
16
0
@@ -12,3 +12,4 @@ require 'spec/rails/matchers'
0
 require 'spec/rails/mocks'
0
 require 'spec/rails/example'
0
 require 'spec/rails/extensions'
0
+require 'spec/rails/interop/testcase'
0
\ No newline at end of file
...
11
12
13
14
15
16
17
18
 
 
 
 
 
 
 
 
 
19
20
21
...
11
12
13
 
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -11,11 +11,15 @@ module Spec
0
       class RailsExampleGroup < Test::Unit::TestCase
0
         
0
         # Rails >= r8570 uses setup/teardown_fixtures explicitly
0
-        before(:each) do
0
-          setup_fixtures if self.respond_to?(:setup_fixtures)
0
-        end
0
-        after(:each) do
0
-          teardown_fixtures if self.respond_to?(:teardown_fixtures)
0
+        # However, Rails >= r8664 extracted these out to use ActiveSupport::Callbacks.
0
+        # The latter case is handled at the TestCase level, in interop/testcase.rb
0
+        unless ActiveSupport.const_defined?(:Callbacks) and self.include?(ActiveSupport::Callbacks)
0
+          before(:each) do
0
+            setup_fixtures if self.respond_to?(:setup_fixtures)
0
+          end
0
+          after(:each) do
0
+            teardown_fixtures if self.respond_to?(:teardown_fixtures)
0
+          end
0
         end
0
         
0
         include Spec::Rails::Matchers

Comments