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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



71
72
73
74
# File 'lib/test_prof/before_all.rb', line 71

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

Instance Attribute Details

#setup_fixturesObject

Returns the value of attribute setup_fixtures.



69
70
71
# File 'lib/test_prof/before_all.rb', line 69

def setup_fixtures
  @setup_fixtures
end

Instance Method Details

#after(type, &block) ⇒ Object

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

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


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

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) { ... }


80
81
82
83
# File 'lib/test_prof/before_all.rb', line 80

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

#run_hooks(type) ⇒ Object

:nodoc:



94
95
96
97
# File 'lib/test_prof/before_all.rb', line 94

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