Module Spec::Example::BeforeAndAfterHooks

  1. lib/spec/example/before_and_after_hooks.rb

Public instance methods

after (scope = :each, &block)

Alias for prepend_after

append_after (scope = :each, &block)

Registers a block to be executed after each example. This method appends block to existing after blocks.

See append_before for scoping semantics.

[show source]
# File lib/spec/example/before_and_after_hooks.rb, line 45
      def append_after(scope = :each, &block)
        after_parts(scope) << block
      end
append_before (scope = :each, &block)

Registers a block to be executed before examples. scope can be :each (default), :all, or :suite. When :each, the block is executed before each example. When :all, the block is executed only once before any examples are run.

[show source]
# File lib/spec/example/before_and_after_hooks.rb, line 19
      def append_before(scope = :each, &block)
        before_parts(scope) << block
      end
before (scope = :each, &block)

Alias for append_before

prepend_after (scope = :each, &block)

Registers a block to be executed after each example. This method prepends block to existing after blocks.

See append_before for scoping semantics.

[show source]
# File lib/spec/example/before_and_after_hooks.rb, line 36
      def prepend_after(scope = :each, &block)
        after_parts(scope).unshift(block)
      end
prepend_before (scope = :each, &block)

Registers a block to be executed before each example. This method prepends block to existing before blocks.

See append_before for scoping semantics.

[show source]
# File lib/spec/example/before_and_after_hooks.rb, line 28
      def prepend_before(scope = :each, &block)
        before_parts(scope).unshift(block)
      end