Sha256: 77fd325fd5d3081cd9eedcb12a35d09a4179389573cb443d58ac30ce0e26e27d

Contents?: true

Size: 884 Bytes

Versions: 6

Compression:

Stored size: 884 Bytes

Contents

module SetupAndTeardownAdapter
  extend ActiveSupport::Concern

  module ClassMethods
    # Wraps `setup` calls from within Rails' testing framework in `before`
    # hooks.
    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

    # @api private
    #
    # Wraps `teardown` calls from within Rails' testing framework in
    # `after` hooks.
    def teardown(*methods, &block)
      methods.each { |method| after { __send__ method } }
      after(&block) if block
    end
  end

  def initialize(*args)
    super
    @example = nil
  end

  def method_name
    @example
  end

  attr_accessor :request, :params
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
paginate-responder-2.1.0 spec/support/05-setup-and-teardown-adapter.rb
paginate-responder-2.0.0 spec/support/05-setup-and-teardown-adapter.rb
paginate-responder-1.8.0 spec/support/05-setup-and-teardown-adapter.rb
paginate-responder-1.7.0 spec/support/05-setup-and-teardown-adapter.rb
paginate-responder-1.6.0 spec/support/05-setup-and-teardown-adapter.rb
paginate-responder-1.6.0.b0 spec/support/05-setup-and-teardown-adapter.rb