Module: EventedSpec::SpecHelper::EventMachineHelpers::ExampleMethods

Included in:
EventedSpec::SpecHelper
Defined in:
lib/evented-spec/spec_helper/event_machine_helpers.rb

Overview

module GroupMethods

Instance Method Summary collapse

Instance Method Details

#em(opts = {}) { ... } ⇒ Object

Yields to block inside EM loop, :spec_timeout option (in seconds) is used to force spec to timeout if something goes wrong and EM/AMQP loop hangs for some reason.

For compatibility with EM-Spec API, em method accepts either options Hash or numeric timeout in seconds.

Parameters:

  • options (Hash)

    for eventmachine

  • opts (Numeric) (defaults to: {})

    :spec_timeout (nil) Amount of time before spec is stopped by timeout

Yields:

  • block to execute after eventmachine loop starts



35
36
37
38
39
# File 'lib/evented-spec/spec_helper/event_machine_helpers.rb', line 35

def em(opts = {}, &block)
  opts = default_options.merge(opts.is_a?(Hash) ? opts : { :spec_timeout =>  opts })
  @evented_example = EMExample.new(opts, self, &block)
  @evented_example.run
end