Sha256: be79bfedfdb4fb16358ede72042d496e6fac29dd20c68c28d8a6ba62e6406a00

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 KB

Contents

RSpec.describe Mutant::Actor::Binding do
  let(:actor_a)    { double('Actor-A', sender: sender_a, receiver: receiver_a) }
  let(:sender_a)   { double('Sender-A')                                        }
  let(:sender_b)   { double('Sender-B')                                        }
  let(:receiver_a) { double('Receiver-A')                                      }
  let(:payload)    { double('Payload')                                         }
  let(:type)       { double('Type')                                            }

  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

18 entries across 18 versions & 1 rubygems

Version Path
mutant-0.8.8 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.7 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.6 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.5 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.4 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.3 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.2 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.1 spec/unit/mutant/actor/binding_spec.rb
mutant-0.8.0 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.9 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.8 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.7 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.6 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.5 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.4 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.3 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.2 spec/unit/mutant/actor/binding_spec.rb
mutant-0.7.1 spec/unit/mutant/actor/binding_spec.rb