Module: RSpec::Rails::SetupAndTeardownAdapter::ClassMethods

Defined in:
lib/rspec/rails/adapters.rb

Instance Method Summary collapse

Instance Method Details

#setup(*methods, &block) ⇒ Object

Wraps setup calls from within Rails' testing framework in before hooks.



160
161
162
163
164
165
166
167
168
169
# File 'lib/rspec/rails/adapters.rb', line 160

def setup(*methods, &block)
  methods.each do |method|
    if method.to_s =~ /^setup_(with_controller|fixtures|controller_request_and_response)$/
      prepend_before { __send__ method }
    else
      before         { __send__ method }
    end
  end
  before(&block) if block
end

#teardown(*methods, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Wraps teardown calls from within Rails' testing framework in after hooks.



175
176
177
178
# File 'lib/rspec/rails/adapters.rb', line 175

def teardown(*methods, &block)
  methods.each { |method| after { __send__ method } }
  after(&block) if block
end