Sha256: 467d81d6ca9b78d601cbb524bd6010919edcfbba822fc2909c37babd8be1a706

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'

module MessageDriver::Message
  describe Base do
    describe "#initialize" do
      let(:body) { "The message body" }
      let(:headers) { { foo: :bar, bar: :baz} }
      let(:properties) { {persistent: true, client_ack: true} }

      context "sets the body, header and properites on initialization" do
        subject { described_class.new(body, headers, properties) }

        its(:body) { should eq(body) }
        its(:headers) { should eq(headers) }
        its(:properties) { should eq(properties) }
      end
    end

    subject(:message) { described_class.new("body", {}, {}) }

    describe "#ack" do
      let(:options) { {foo: :bar} }

      before do
        MessageDriver::Client.stub(:ack_message)
      end
      it "passes itself to Client.ack_message" do
        subject.ack
        expect(MessageDriver::Client).to have_received(:ack_message).with(subject, {})
      end

      it "passes the options to Client.ack_message" do
        subject.ack(options)
        expect(MessageDriver::Client).to have_received(:ack_message).with(subject, options)
      end
    end

    describe "#nack" do
      let(:options) { {foo: :bar} }

      before do
        MessageDriver::Client.stub(:nack_message)
      end
      it "passes itself to Client.nack_message" do
        subject.nack
        expect(MessageDriver::Client).to have_received(:nack_message).with(subject, {})
      end

      it "passes the options to Client.nack_message" do
        subject.nack(options)
        expect(MessageDriver::Client).to have_received(:nack_message).with(subject, options)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message-driver-0.2.2 spec/units/message_driver/message_spec.rb
message-driver-0.2.1 spec/units/message_driver/message_spec.rb
message-driver-0.2.0 spec/units/message_driver/message_spec.rb
message-driver-0.2.0.rc2 spec/units/message_driver/message_spec.rb
message-driver-0.2.0.rc1 spec/units/message_driver/message_spec.rb