Sha256: 605aa6b939698346ce9cb12aff0756a0b1acdf0b9d825423a1b738679815b363

Contents?: true

Size: 852 Bytes

Versions: 9

Compression:

Stored size: 852 Bytes

Contents

require File.expand_path("../spec_helper", __FILE__)

module Euston
  describe 'aggregate root' do
    context 'duplicate command consumption' do
      let(:aggregate) { Sample::Widget.new }
      let(:aggregate2) { Sample::Widget.new }
      let(:command) { { :headers => CommandHeaders.new(id: Euston.uuid.generate, type: 'create_widget', version: 1),
                        :body => { :id => Euston.uuid.generate } } }

      it 'does not handle the same command twice' do
        aggregate.consume_command command[:headers], command[:body]
        aggregate.uncommitted_events.should have(1).item

        aggregate.uncommitted_events.each { |e| aggregate2.replay_event e.headers, e.body }

        aggregate2.consume_command command[:headers], command[:body]
        aggregate2.uncommitted_events.should have(0).items
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
euston-1.2.8 spec/aggregate_root_spec.rb
euston-1.2.8-java spec/aggregate_root_spec.rb
euston-1.2.7-java spec/aggregate_root_spec.rb
euston-1.2.7 spec/aggregate_root_spec.rb
euston-1.2.6 spec/aggregate_root_spec.rb
euston-1.2.5-java spec/aggregate_root_spec.rb
euston-1.2.5 spec/aggregate_root_spec.rb
euston-1.2.4-java spec/aggregate_root_spec.rb
euston-1.2.4 spec/aggregate_root_spec.rb