Sha256: 0eb6eb1383be3bf7e3b9b96349ded24d97cdba1dacad1060c19b526e3d8ec7cc

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

module EventedSpec
  # Including EventedSpec::EMSpec module into your example group, each example of this group
  # will run inside EM.run loop without the need to explicitly call 'em'.
  #
  module EMSpec
    def self.included(example_group)
      example_group.send(:include, SpecHelper)
      example_group.extend ClassMethods
    end

    # @private
    module ClassMethods
      def it(*args, &block)
        if block
          # Shared example groups seem to pass example group instance
          # to the actual example block
          new_block = lambda do |*args|
            em(&block)
          end
          super(*args, &new_block)
        else
          # pending example
          super
        end
      end # it
    end # ClassMethods
  end # EMSpec
end # module EventedSpec

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evented-spec-1.0.0.beta1 lib/evented-spec/em_spec.rb