Sha256: 14537c902e49d8fe4d535b21ae54c51560b50801153ed3b80452c65a144dede3

Contents?: true

Size: 1.38 KB

Versions: 8

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

RSpec.describe Mutant::Actor::Binding do
  let(:actor_a)    { instance_double(Mutant::Actor::Mailbox, sender: sender_a, receiver: receiver_a) }
  let(:sender_a)   { instance_double(Mutant::Actor::Sender)                                          }
  let(:sender_b)   { instance_double(Mutant::Actor::Sender)                                          }
  let(:receiver_a) { instance_double(Mutant::Actor::Receiver)                                        }
  let(:payload)    { instance_double(Object)                                                         }
  let(:type)       { instance_double(Symbol)                                                         }

  let(:object) { described_class.new(actor_a, sender_b) }

  describe '#call' do
    subject { object.call(type) }

    before do
      expect(sender_b).to receive(:call).with(message(type, sender_a)).ordered
      expect(receiver_a).to receive(:call).ordered.and_return(message(response_type, payload))
    end

    context 'when return type equals request type' do
      let(:response_type) { type }
      it { should be(payload) }
    end

    context 'when return type NOT equals request type' do
      let(:response_type) { double('Other Type') }

      it 'raises error' do
        expect { subject }.to raise_error(Mutant::Actor::ProtocolError, "Expected #{type} but got #{response_type}")
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.24 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.23 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.22 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.21 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.20 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.19 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.18 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.17 spec/unit/mutant/actor/binding_spec.rb