Module: TestFrameworkHooks
- Included in:
- Hyperion
- Defined in:
- lib/hyperion_test/test_framework_hooks.rb
Instance Method Summary collapse
- #can_hook_reset? ⇒ Boolean
- #hook_reset ⇒ Object
- #reset_registered? ⇒ Boolean
- #rspec_after_example_hooks ⇒ Object
- #rspec_hooks ⇒ Object
Instance Method Details
#can_hook_reset? ⇒ Boolean
11 12 13 |
# File 'lib/hyperion_test/test_framework_hooks.rb', line 11 def can_hook_reset? !!RSpec.current_example end |
#hook_reset ⇒ Object
15 16 17 18 |
# File 'lib/hyperion_test/test_framework_hooks.rb', line 15 def hook_reset hyperion = self rspec_hooks.register(:prepend, :after, :each) { hyperion.reset } end |
#reset_registered? ⇒ Boolean
5 6 7 8 9 |
# File 'lib/hyperion_test/test_framework_hooks.rb', line 5 def reset_registered? rspec_after_example_hooks.any? do |hook_proc| hook_proc.source_location == method(:reset).to_proc.source_location end end |
#rspec_after_example_hooks ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hyperion_test/test_framework_hooks.rb', line 20 def rspec_after_example_hooks if rspec_hooks.respond_to?(:[]) # approximately rspec 3.1.0 rspec_hooks[:after][:example].to_a.map(&:block) else # approximately rspec 3.3.0 default_if_no_hooks = nil hook_collection = rspec_hooks.send(:hooks_for, :after, :example) {default_if_no_hooks} return [] unless hook_collection hook_collection.items_and_filters.map(&:first).map(&:block) end end |
#rspec_hooks ⇒ Object
31 32 33 |
# File 'lib/hyperion_test/test_framework_hooks.rb', line 31 def rspec_hooks RSpec.current_example.example_group.hooks end |