Sha256: 0cf60944dce0d6b9c0d6ac784c82041efbf5bc39617ec3cc0ce86a4c8bb6d67e

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

shared_examples "a destination" do
  describe "#pop_message" do
    let(:body) { "The message body" }
    let(:headers) { { "foo" => "bar", "bar" => "baz"} }
    let(:properties) { {persistent: true, client_ack: true} }

    before do
      destination.publish(body, headers, properties)
    end

    context "the result" do
      subject(:message) { destination.pop_message }

      it { should be_a MessageDriver::Message::Base }
      its(:body) { should eq(body) }
      its(:headers) { should include(headers) }
      its(:properties) { should_not be_nil }
    end
  end
end

shared_examples "doesn't support #message_count" do
  describe "#message_count" do
    it "raises an error" do
      expect {
        destination.message_count
      }.to raise_error "#message_count is not supported by #{destination.class}"
    end
  end
end

shared_examples "supports #message_count" do
  it "reports it's message_count" do
    expect {
      destination.publish("msg1")
      destination.publish("msg2")
      pause_if_needed
    }.to change{destination.message_count}.by(2)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
message-driver-0.2.2 spec/support/shared/destination_examples.rb
message-driver-0.2.1 spec/support/shared/destination_examples.rb
message-driver-0.2.0 spec/support/shared/destination_examples.rb
message-driver-0.2.0.rc2 spec/support/shared/destination_examples.rb
message-driver-0.2.0.rc1 spec/support/shared/destination_examples.rb