Module: AMQP::SpecHelper::GroupMethods
- Defined in:
- lib/amqp-spec/rspec.rb
Overview
Class methods (macros) for any example groups that includes SpecHelper. You can use these methods as macros inside describe/context block.
Instance Method Summary collapse
-
#amqp_after(scope = :each, &block) ⇒ Object
Add after hook that will run inside AMQP connection (AMQP.start loop).
-
#amqp_before(scope = :each, &block) ⇒ Object
Add before hook that will run inside AMQP connection (AMQP.start loop).
-
#default_options(opts = nil) ⇒ Object
Sets/retrieves default AMQP.start options for this example group and its nested groups.
-
#default_timeout(spec_timeout = nil) ⇒ Object
Sets/retrieves default timeout for running evented specs for this example group and its nested groups.
-
#em_after(scope = :each, &block) ⇒ Object
Add after hook that will run inside EM event loop.
-
#em_before(scope = :each, &block) ⇒ Object
Add before hook that will run inside EM event loop.
-
#em_hooks ⇒ Object
Collection of evented hooks for THIS example group.
-
#metadata ⇒ Object
Hacking in metadata into RSpec1 to imitate Rspec2’s metadata.
Instance Method Details
#amqp_after(scope = :each, &block) ⇒ Object
Add after hook that will run inside AMQP connection (AMQP.start loop)
88 89 90 91 |
# File 'lib/amqp-spec/rspec.rb', line 88 def amqp_after(scope = :each, &block) raise ArgumentError, "amqp_after only supports :each scope" unless :each == scope em_hooks[:amqp_after].unshift block end |
#amqp_before(scope = :each, &block) ⇒ Object
Add before hook that will run inside AMQP connection (AMQP.start loop)
82 83 84 85 |
# File 'lib/amqp-spec/rspec.rb', line 82 def amqp_before(scope = :each, &block) raise ArgumentError, "amqp_before only supports :each scope" unless :each == scope em_hooks[:amqp_before] << block end |
#default_options(opts = nil) ⇒ Object
Sets/retrieves default AMQP.start options for this example group and its nested groups.
63 64 65 66 67 |
# File 'lib/amqp-spec/rspec.rb', line 63 def (opts = nil) [:em_defaults] ||= {} [:em_defaults][self] ||= (superclass..dup rescue {}) [:em_defaults][self] = opts || [:em_defaults][self] end |
#default_timeout(spec_timeout = nil) ⇒ Object
Sets/retrieves default timeout for running evented specs for this example group and its nested groups.
56 57 58 |
# File 'lib/amqp-spec/rspec.rb', line 56 def default_timeout(spec_timeout = nil) [:spec_timeout] = spec_timeout || [:spec_timeout] end |
#em_after(scope = :each, &block) ⇒ Object
Add after hook that will run inside EM event loop
76 77 78 79 |
# File 'lib/amqp-spec/rspec.rb', line 76 def em_after(scope = :each, &block) raise ArgumentError, "em_after only supports :each scope" unless :each == scope em_hooks[:em_after].unshift block end |
#em_before(scope = :each, &block) ⇒ Object
Add before hook that will run inside EM event loop
70 71 72 73 |
# File 'lib/amqp-spec/rspec.rb', line 70 def em_before(scope = :each, &block) raise ArgumentError, "em_before only supports :each scope" unless :each == scope em_hooks[:em_before] << block end |
#em_hooks ⇒ Object
Collection of evented hooks for THIS example group
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/amqp-spec/rspec.rb', line 94 def em_hooks [:em_hooks] ||= {} [:em_hooks][self] ||= { :em_before => (superclass.em_hooks[:em_before].clone rescue []), :em_after => (superclass.em_hooks[:em_after].clone rescue []), :amqp_before => (superclass.em_hooks[:amqp_before].clone rescue []), :amqp_after => (superclass.em_hooks[:amqp_after].clone rescue []) } end |
#metadata ⇒ Object
Hacking in metadata into RSpec1 to imitate Rspec2’s metadata. Now you can add anything to metadata Hash to pass options into examples and nested groups.
48 49 50 |
# File 'lib/amqp-spec/rspec.rb', line 48 def @metadata ||= superclass..dup rescue {} end |