Class: TestProf::BeforeAll::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/test_prof/before_all.rb

Constant Summary collapse

HOOKS =
%i[begin rollback].freeze

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



67
68
69
# File 'lib/test_prof/before_all.rb', line 67

def initialize
  @hooks = Hash.new { |h, k| h[k] = HooksChain.new(k) }
end

Instance Method Details

#after(type, &block) ⇒ Object

Add ‘after` hook for `begin` or `rollback` operation:

config.after(:begin) { ... }


84
85
86
87
# File 'lib/test_prof/before_all.rb', line 84

def after(type, &block)
  validate_hook_type!(type)
  hooks[type].after << block if block_given?
end

#before(type, &block) ⇒ Object

Add ‘before` hook for `begin` or `rollback` operation:

config.before(:rollback) { ... }


75
76
77
78
# File 'lib/test_prof/before_all.rb', line 75

def before(type, &block)
  validate_hook_type!(type)
  hooks[type].before << block if block_given?
end

#run_hooks(type) ⇒ Object

:nodoc:



89
90
91
92
# File 'lib/test_prof/before_all.rb', line 89

def run_hooks(type) # :nodoc:
  validate_hook_type!(type)
  hooks[type].run { yield }
end