Class: TestProf::BeforeAll::Configuration
- Inherits:
-
Object
- Object
- TestProf::BeforeAll::Configuration
- Defined in:
- lib/test_prof/before_all.rb
Constant Summary collapse
- HOOKS =
%i[begin rollback].freeze
Instance Attribute Summary collapse
-
#setup_fixtures ⇒ Object
Returns the value of attribute setup_fixtures.
Instance Method Summary collapse
-
#after(type, *filters, &block) ⇒ Object
Add ‘after` hook for `begin` or `rollback` operation with optional filters:.
-
#before(type, *filters, &block) ⇒ Object
Add ‘before` hook for `begin` or `rollback` operation with optional filters:.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#run_hooks(type, scope = nil, metadata = []) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
129 130 131 132 |
# File 'lib/test_prof/before_all.rb', line 129 def initialize @hooks = Hash.new { |h, k| h[k] = HooksChain.new(k) } @setup_fixtures = false end |
Instance Attribute Details
#setup_fixtures ⇒ Object
Returns the value of attribute setup_fixtures.
127 128 129 |
# File 'lib/test_prof/before_all.rb', line 127 def setup_fixtures @setup_fixtures end |
Instance Method Details
#after(type, *filters, &block) ⇒ Object
Add ‘after` hook for `begin` or `rollback` operation with optional filters:
config.after(:begin, foo: :bar) { ... }
147 148 149 150 |
# File 'lib/test_prof/before_all.rb', line 147 def after(type, *filters, &block) validate_hook_type!(type) hooks[type].after << HookEntry.new(block: block, filters: filters) if block end |
#before(type, *filters, &block) ⇒ Object
Add ‘before` hook for `begin` or `rollback` operation with optional filters:
config.before(:rollback, foo: :bar) { ... }
138 139 140 141 |
# File 'lib/test_prof/before_all.rb', line 138 def before(type, *filters, &block) validate_hook_type!(type) hooks[type].before << HookEntry.new(block: block, filters: filters) if block end |
#run_hooks(type, scope = nil, metadata = []) ⇒ Object
:nodoc:
152 153 154 155 |
# File 'lib/test_prof/before_all.rb', line 152 def run_hooks(type, scope = nil, = []) # :nodoc: validate_hook_type!(type) hooks[type].run(scope, ) { yield } end |