Module: ActiveSupport::Testing::SetupAndTeardown
- Included in:
 - ActiveSupport::TestCase
 
- Defined in:
 - lib/active_support/testing/setup_and_teardown.rb
 
Overview
Adds support for setup and teardown callbacks. These callbacks serve as a replacement to overwriting the #setup and #teardown methods of your TestCase.
class ExampleTest < ActiveSupport::TestCase
  setup do
    # ...
  end
  teardown do
    # ...
  end
end
  Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #after_teardown  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 - 
  
    
      #before_setup  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
:nodoc:.
 
Class Method Details
.prepended(klass) ⇒ Object
      21 22 23 24 25  | 
    
      # File 'lib/active_support/testing/setup_and_teardown.rb', line 21 def self.prepended(klass) klass.include ActiveSupport::Callbacks klass.define_callbacks :setup, :teardown klass.extend ClassMethods end  | 
  
Instance Method Details
#after_teardown ⇒ Object
:nodoc:
      44 45 46 47 48 49 50 51 52 53 54  | 
    
      # File 'lib/active_support/testing/setup_and_teardown.rb', line 44 def after_teardown # :nodoc: begin run_callbacks :teardown rescue => e self.failures << Minitest::UnexpectedError.new(e) rescue Minitest::Assertion => e self.failures << e end super end  | 
  
#before_setup ⇒ Object
:nodoc:
      39 40 41 42  | 
    
      # File 'lib/active_support/testing/setup_and_teardown.rb', line 39 def before_setup # :nodoc: super run_callbacks :setup end  |