Module: Spec::Example::BeforeAndAfterHooks
- Included in:
- ExampleGroupMethods
- Defined in:
- lib/spec/example/before_and_after_hooks.rb
Class Method Summary collapse
-
.after_suite_parts ⇒ Object
:nodoc:.
-
.before_suite_parts ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#after_all_parts ⇒ Object
:nodoc:.
-
#after_each_parts ⇒ Object
:nodoc:.
-
#after_suite_parts ⇒ Object
:nodoc:.
-
#append_after(scope = :each, &block) ⇒ Object
Registers a block to be executed after each example.
-
#append_before(scope = :each, &block) ⇒ Object
(also: #before)
Registers a block to be executed before examples.
-
#before_all_parts ⇒ Object
:nodoc:.
-
#before_each_parts ⇒ Object
:nodoc:.
-
#before_suite_parts ⇒ Object
:nodoc:.
-
#prepend_after(scope = :each, &block) ⇒ Object
(also: #after)
Registers a block to be executed after each example.
-
#prepend_before(scope = :each, &block) ⇒ Object
Registers a block to be executed before each example.
Class Method Details
.after_suite_parts ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 9 def after_suite_parts # :nodoc: @after_suite_parts ||= [] end |
.before_suite_parts ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 5 def before_suite_parts # :nodoc: @before_suite_parts ||= [] end |
Instance Method Details
#after_all_parts ⇒ Object
:nodoc:
61 62 63 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 61 def after_all_parts # :nodoc: @after_all_parts ||= [] end |
#after_each_parts ⇒ Object
:nodoc:
53 54 55 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 53 def after_each_parts # :nodoc: @after_each_parts ||= [] end |
#after_suite_parts ⇒ Object
:nodoc:
69 70 71 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 69 def after_suite_parts # :nodoc: BeforeAndAfterHooks.after_suite_parts end |
#append_after(scope = :each, &block) ⇒ Object
Registers a block to be executed after each example. This method appends block
to existing after blocks.
See append_before
for scoping semantics.
45 46 47 |
# 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) ⇒ Object Also known as: before
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.
19 20 21 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 19 def append_before(scope = :each, &block) before_parts(scope) << block end |
#before_all_parts ⇒ Object
:nodoc:
57 58 59 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 57 def before_all_parts # :nodoc: @before_all_parts ||= [] end |
#before_each_parts ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 49 def before_each_parts # :nodoc: @before_each_parts ||= [] end |
#before_suite_parts ⇒ Object
:nodoc:
65 66 67 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 65 def before_suite_parts # :nodoc: BeforeAndAfterHooks.before_suite_parts end |
#prepend_after(scope = :each, &block) ⇒ Object Also known as: after
Registers a block to be executed after each example. This method prepends block
to existing after blocks.
See append_before
for scoping semantics.
36 37 38 |
# 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) ⇒ Object
Registers a block to be executed before each example. This method prepends block
to existing before blocks.
See append_before
for scoping semantics.
28 29 30 |
# File 'lib/spec/example/before_and_after_hooks.rb', line 28 def prepend_before(scope = :each, &block) before_parts(scope).unshift(block) end |