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.
100 101 102 103 |
# File 'lib/test_prof/before_all.rb', line 100 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.
98 99 100 |
# File 'lib/test_prof/before_all.rb', line 98 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) { ... }
118 119 120 121 |
# File 'lib/test_prof/before_all.rb', line 118 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) { ... }
109 110 111 112 |
# File 'lib/test_prof/before_all.rb', line 109 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:
123 124 125 126 |
# File 'lib/test_prof/before_all.rb', line 123 def run_hooks(type, scope = nil, = []) # :nodoc: validate_hook_type!(type) hooks[type].run(scope, ) { yield } end |