Skip to content

Instantly share code, notes, and snippets.

@Papipo
Last active August 29, 2015 14:04
Show Gist options
  • Save Papipo/4064648445f1bfc00391 to your computer and use it in GitHub Desktop.
Save Papipo/4064648445f1bfc00391 to your computer and use it in GitHub Desktop.
require "unit_helper"
require "event_sourcing/event/bus/stream"
describe EventSourcing::Event::Bus::Stream do
let(:bus_stream) { EventSourcing::Event::Bus::Stream.new(store_stream, event_bus) }
let(:store_stream) { instance_double("EventSourcing::Event::Store::Stream") }
let(:event_bus) { instance_double("EventSourcing::Event::Bus::Reference") }
context "each" do
before do
# allow call to store_stream.each with block here
end
let(:enumerable) { double("Enumerable") }
let(:block) { lambda {} }
it "delegates to the store stream" do
expect(bus_stream.each(&block)).to eq(enumerable)
end
it "is an enumerable" do
expect(bus_stream).to be_a(Enumerable)
end
end
end
@cupakromer
Copy link

it "is an Enumerable" do
  expect(bus_stream).to be_a(Enumerable)
end

it "delegates `each` to the store" do
  received_block = nil
  store_stream = instance_double("StoreStream")
  allow(store_stream).to receive(:each) { |&b| received_block = b }
  some_action = lambda {}

  bus_stream.each(&some_action)

  expect(received_block).to be some_action
end

@Papipo
Copy link
Author

Papipo commented Aug 4, 2014

  context "each" do
    before do
      @received_block = nil
      allow(store_stream).to receive(:each) { |&b| @received_block = b }
      bus_stream.each(&block)
    end

    let(:block) { lambda {} }

    it "delegates to the store stream" do
      expect(@received_block).to be(block)
    end

    it "is an enumerable" do
      expect(bus_stream).to be_a(Enumerable)
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment