Sha256: a6b492614b8aba5aed1129df32189d58fa41709540f5bba6bb9838eb73974965

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'rspec'
require 'mercury/test_utils'
require 'mercury/fake'
include Mercury::TestUtils

# the block must return a Cps
def test_with_mercury_cps(sources, queues, parallelism: 1, &block)
  em do
    seql do
      let(:m)  { Mercury::Monadic.open(parallelism: parallelism) }
      and_then { delete_sources_and_queues_cps(sources, queues) }
      and_then { block.call(m) }
      and_then { delete_sources_and_queues_cps(sources, queues) }
      and_then { m.close }
      and_lift { done }
    end.run
  end
end

module MercuryFakeSpec
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    # runs a test once with real mercury and once with Mercury::Fake
    def itt(name, &block)
      it(name, &block)
      context 'with Mercury::Fake' do
        before :each do
          allow(Mercury).to receive(:open) do |parallelism:1, &k|
            EM.next_tick { k.call(Mercury::Fake.new(parallelism: parallelism)) }
          end
        end
        it(name, &block)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mercury_amqp-0.1.9 spec/spec_helper.rb
mercury_amqp-0.1.7 spec/spec_helper.rb
mercury_amqp-0.1.6 spec/spec_helper.rb
mercury_amqp-0.1.5 spec/spec_helper.rb