Skip to content

BunnyMock::Queue#pop api does not match Bunny::Queue#pop #15

@podung

Description

@podung

I see that BunnyMock::Queue#pop returns a hash with :message and :options keys:

xchg.publish("Hello, everybody!", :routing_key => 'test1')

message = q.pop
message[:message]    # => 'Hello, everybody!'
message[:options]    # => { routing_key: 'test1' }

However Bunny::Queue#pop returns a 3 element array:

xchg.publish("Hello, everybody!", :routing_key => 'test1')

delivery_info, properties, payload = q.pop

I assume that this was to make popping messages off of queues in specs a lot cleaner. However, it makes BunnyMock only really able to help test the publishing of messages. Any code that attempts to use Bunny to read messages from queues would not be able to use BunnyMock.new as a replacement for Bunny.new.

Ideally the APIs would match, however changing it would break anyone using the current behavior. I propose creating some sort of config option (e.g. BunnyMock.use_bunny_queue_pop_api = true) that could default to the current behavior. The README could clearly show how to use the two options.

Thoughts? Let me know if I'm misunderstanding something.

I'll put together a PR if you're open to the idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions