Module: EventedSpec::SpecHelper::GroupMethods

Includes:
AMQPHelpers::GroupMethods, CoolioHelpers::GroupHelpers, EventMachineHelpers::GroupMethods
Defined in:
lib/evented-spec/spec_helper.rb,
lib/evented-spec/spec_helper/amqp_helpers.rb,
lib/evented-spec/spec_helper/coolio_helpers.rb,
lib/evented-spec/spec_helper/event_machine_helpers.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

Methods included from EventMachineHelpers::GroupMethods

#em_after, #em_before

Methods included from CoolioHelpers::GroupHelpers

#coolio_after, #coolio_before

Methods included from AMQPHelpers::GroupMethods

#amqp_after, #amqp_before

Instance Method Details

#default_options(opts = nil) ⇒ Hash

Sets/retrieves default AMQP.start options for this example group and its nested groups.

Parameters:

  • context-specific (Hash)

    options for helper methods like #amqp, #em, #coolio

Returns:

  • (Hash)


71
72
73
74
75
76
77
78
# File 'lib/evented-spec/spec_helper.rb', line 71

def default_options(opts = nil)
  [:default_options] ||= {}
  if opts
    [:default_options].merge!(opts)
  else
    [:default_options]
  end
end

#default_timeout(spec_timeout = nil) ⇒ Float

Sets/retrieves default timeout for running evented specs for this example group and its nested groups.

Parameters:

  • desired (Float)

    timeout for the example group

Returns:

  • (Float)


58
59
60
61
62
63
64
# File 'lib/evented-spec/spec_helper.rb', line 58

def default_timeout(spec_timeout = nil)
  if spec_timeout
    default_options[:spec_timeout] = spec_timeout
  else
    default_options[:spec_timeout] || self.superclass.default_timeout
  end
end

#evented_spec_hooksHash

Collection of evented hooks for current example group

Returns:

  • (Hash)

    hash with hooks



83
84
85
# File 'lib/evented-spec/spec_helper.rb', line 83

def evented_spec_hooks
  [:es_hooks] ||= Hash.new
end

#evented_spec_hooks_for(type) ⇒ Array

Collection of evented hooks of predefined type for current example group

Parameters:

  • hook (Symbol)

    type

Returns:

  • (Array)

    hooks



91
92
93
# File 'lib/evented-spec/spec_helper.rb', line 91

def evented_spec_hooks_for(type)
  evented_spec_hooks[type] ||= []
end

#evented_spec_metadataHash

Returns evented-spec related metadata for particular example group. Metadata is cloned from parent to children, so that children inherit all the options and hooks set in parent example groups

Returns:

  • (Hash)

    hash with example group metadata



44
45
46
47
48
49
50
51
# File 'lib/evented-spec/spec_helper.rb', line 44

def 
  if @evented_spec_metadata
    @evented_spec_metadata
  else
    @evented_spec_metadata = superclass. rescue {}
    @evented_spec_metadata = EventedSpec::Util.deep_clone(@evented_spec_metadata)
  end
end