Module: Spec::Example::BeforeAndAfterHooks

Included in:
ExampleGroupMethods
Defined in:
lib/spec/example/before_and_after_hooks.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.after_suite_partsObject



9
10
11
# File 'lib/spec/example/before_and_after_hooks.rb', line 9

def after_suite_parts
  @after_suite_parts ||= []
end

.before_suite_partsObject



5
6
7
# File 'lib/spec/example/before_and_after_hooks.rb', line 5

def before_suite_parts
  @before_suite_parts ||= []
end

Instance Method Details

#after_all_partsObject

:nodoc:



52
53
54
# File 'lib/spec/example/before_and_after_hooks.rb', line 52

def after_all_parts # :nodoc:
  @after_all_parts ||= []
end

#after_each_partsObject

:nodoc:



44
45
46
# File 'lib/spec/example/before_and_after_hooks.rb', line 44

def after_each_parts # :nodoc:
  @after_each_parts ||= []
end

#after_suite_partsObject



60
61
62
# File 'lib/spec/example/before_and_after_hooks.rb', line 60

def after_suite_parts
  BeforeAndAfterHooks.after_suite_parts
end

#append_after(*args, &block) ⇒ Object

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



36
37
38
# File 'lib/spec/example/before_and_after_hooks.rb', line 36

def append_after(*args, &block)
  after_parts(*args) << block
end

#append_before(*args, &block) ⇒ Object Also known as: before

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



22
23
24
# File 'lib/spec/example/before_and_after_hooks.rb', line 22

def append_before(*args, &block)
  before_parts(*args) << block
end

#before_all_partsObject

:nodoc:



48
49
50
# File 'lib/spec/example/before_and_after_hooks.rb', line 48

def before_all_parts # :nodoc:
  @before_all_parts ||= []
end

#before_each_partsObject

:nodoc:



40
41
42
# File 'lib/spec/example/before_and_after_hooks.rb', line 40

def before_each_parts # :nodoc:
  @before_each_parts ||= []
end

#before_suite_partsObject



56
57
58
# File 'lib/spec/example/before_and_after_hooks.rb', line 56

def before_suite_parts
  BeforeAndAfterHooks.before_suite_parts
end

#prepend_after(*args, &block) ⇒ Object Also known as: after

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



29
30
31
# File 'lib/spec/example/before_and_after_hooks.rb', line 29

def prepend_after(*args, &block)
  after_parts(*args).unshift(block)
end

#prepend_before(*args, &block) ⇒ Object

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



16
17
18
# File 'lib/spec/example/before_and_after_hooks.rb', line 16

def prepend_before(*args, &block)
  before_parts(*args).unshift(block)
end