Permalink
Browse files

let's pretend that never happened...

  • Loading branch information...
1 parent 46657ff commit beb176a666174e6ed7920943b4098ccc0361b139 @paukul committed Nov 3, 2010
Showing with 11 additions and 6 deletions.
  1. +3 −1 lib/amqp_logging.rb
  2. +1 −1 lib/amqp_logging/log_device.rb
  3. +1 −1 lib/amqp_logging/logger.rb
  4. +5 −3 test/logger_test.rb
  5. +1 −0 test/test_helper.rb
View
4 lib/amqp_logging.rb
@@ -1,7 +1,9 @@
require 'bunny'
begin
- require 'active_support/time' # ActiveSupport 3.x
+ # ActiveSupport 3.x
+ require 'active_support/time'
+ require 'active_support/core_ext/hash/slice'
rescue LoadError
require 'active_support' # ActiveSupport 2.x
end
View
2 lib/amqp_logging/log_device.rb
@@ -58,7 +58,7 @@ def exchange
end
def bunny
- @bunny ||= Bunny.new(configuration)
+ @bunny ||= Bunny.new(configuration.slice(:host, :port, :user, :pass))
@bunny
end
View
2 lib/amqp_logging/logger.rb
@@ -5,7 +5,7 @@ class AMQPLogging::Logger < ::Logger
:host => "localhost",
:exchange => "logging_exchange",
:queue => "logging_queue",
- :routing_key => "logs"
+ :routing_key => "logs",
:exchange_durable => true,
:exchange_auto_delete => false,
:exchange_type => :topic,
View
8 test/logger_test.rb
@@ -13,7 +13,7 @@ def setup
end
test "should be instanciated with an amqp configuration hash" do
- config = { :queue => "testqueue", :exchange => "testexchange", :host => "testhost", :shift_age => 4, :shift_size => 1338, :routing_key => "foobar" }
+ config = { :queue => "testqueue", :exchange => "testexchange", :host => "testhost", :shift_age => 4, :shift_size => 1338, :routing_key => "foobar", :exchange_durable => true, :exchange_auto_delete => false, :exchange_type => :topic }
AMQPLogging::LogDevice.expects(:new).with(anything, config).returns(stub_everything)
logger = AMQPLogging::Logger.new(@io, config)
@@ -72,8 +72,10 @@ class TheLogDeviceTest < Test::Unit::TestCase
test "should initialize the AMQP components correctly" do
config = { :queue => "testqueue", :exchange => "testexchange", :host => "testhost", :shift_age => 4, :shift_size => 1338 }
bunny_stub = stub_everything("bunny_stub")
- Bunny.expects(:new).with(config.merge({:routing_key => "logs"})).returns(bunny_stub)
- bunny_stub.expects(:exchange).with(config[:exchange], :type => :topic).returns(stub("exchange stub", :publish => true))
+ Bunny.expects(:new).with(:host => "testhost").returns(bunny_stub)
+ bunny_stub.expects(:exchange).with(config[:exchange], :durable => true,
+ :auto_delete => false,
+ :type => :topic).returns(stub("exchange stub", :publish => true))
logger = AMQPLogging::Logger.new(StringIO.new, config)
logger.debug("foobar")
View
1 test/test_helper.rb
@@ -1,3 +1,4 @@
+$:.unshift(File.expand_path('../../lib', __FILE__))
require 'rubygems'
require 'test/unit'
require 'mocha'

0 comments on commit beb176a

Please sign in to comment.