StuffedBunny
Provides stubbing of the Bunny gem to faciliate testing.
A routed_messages
array captures any publised messages on a topic exchange.
Example Usage
require 'stuffed_bunny' # Bunny is overriden once this is required
class SomeTest < TestUnit::TestCase
def setup
@bunny = Bunny::Client.new
end
def teardown
StuffedBunny.reset! # resets the routed_messages
end
def
= { } # set it to be a topic exchange, etc.
Bunny.run do |b|
topic_exchange = b.exchange( "a_topic_exchange", )
= { :key => "a.routing.key" }
topic_exchange.publish("a message", )
end
= @bunny.exchanges["a_topic_exchange"].[0]
assert_equal "a.routing.key", .key
assert_equal "a message", .
end
end
Installation
Add this line to your application's Gemfile:
group :test do
# Note that as soon as the gem is required, Bunny is overridden.
gem 'stuffed_bunny', :require => false
end
And then execute:
$ bundle
Or install it yourself as:
$ gem install stuffed_bunny
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request