Permalink
Browse files

Fixing deprecation issues with amqp

Adjusting Rspec tests to pass
  • Loading branch information...
Samer Masry Samer Masry
Samer Masry authored and Samer Masry committed Apr 13, 2011
1 parent 5a80056 commit 5447466dd7f52f86d26371ba3444899a9f237824
View
@@ -1,6 +1,5 @@
require 'rubygems'
require 'amqp'
-require 'mq'
require 'json'
require 'logger'
require 'yaml'
View
@@ -38,7 +38,7 @@ def close_connection
# Exchange objects. This allows us to send messeages to exchanges that are
# declared by the mappers and that we have no configuration priviledges on.
# temporary until we get this into amqp proper
-MQ::Exchange.class_eval do
+AMQP::Exchange.class_eval do
def initialize(mq, type, name, opts = {})
@mq = mq
@type, @name, @opts = type, name, opts
View
@@ -16,10 +16,10 @@ def initialize(action, packet, serializers, msg = nil)
# The secure serializer should not be part of the cascading
def initialize(preferred_format = nil)
@preferred_format = preferred_format || :marshal
- if @preferred_format.to_s == 'secure'
+ if @preferred_format == :secure
@serializers = [ SecureSerializer ]
else
- preferred_serializer = SERIALIZERS[@preferred_format.to_sym]
+ preferred_serializer = SERIALIZERS[@preferred_format]
@serializers = SERIALIZERS.values.clone
@serializers.unshift(@serializers.delete(preferred_serializer)) if preferred_serializer
end
View
@@ -4,7 +4,7 @@
describe "Default Option" do
- before(:all) do
+ before(:each) do
EM.stub!(:add_periodic_timer)
AMQP.stub!(:connect)
@amq = mock("AMQueue", :queue => mock("queue", :subscribe => {}), :fanout => mock("fanout", :publish => nil))
@@ -4,12 +4,12 @@
include SpecHelpers
- before(:all) do
+ before(:each) do
@signer, key = issue_cert
@recipient, key = issue_cert
@store = mock("Store")
@proxy = Nanite::CachedCertificateStoreProxy.new(@store)
- end
+ end
it 'should not raise and return nil for non existent certificates' do
res = nil
View
@@ -5,24 +5,18 @@
describe "Format" do
it "supports JSON format" do
- [ :json, "json" ].each do |format|
- serializer = Nanite::Serializer.new(format)
- serializer.instance_eval { @serializers.first }.should == JSON
- end
+ serializer = Nanite::Serializer.new(:json)
+ serializer.instance_eval { @serializers.first }.should == JSON
end
it "supports Marshal format" do
- [ :marshal, "marshal" ].each do |format|
- serializer = Nanite::Serializer.new(format)
- serializer.instance_eval { @serializers.first }.should == Marshal
- end
+ serializer = Nanite::Serializer.new(:marshal)
+ serializer.instance_eval { @serializers.first }.should == Marshal
end
it "supports YAML format" do
- [ :yaml, "yaml" ].each do |format|
- serializer = Nanite::Serializer.new(format)
- serializer.instance_eval { @serializers.first }.should == YAML
- end
+ serializer = Nanite::Serializer.new(:yaml)
+ serializer.instance_eval { @serializers.first }.should == YAML
end
it "should default to Marshal format if not specified" do
@@ -74,8 +68,8 @@
end
it "should override the preferred format and use an insecure one when asked for" do
- JSON.should_receive(:dump).with("packet").and_return(@packet)
- @serializer.dump("packet", :insecure).should == 'serialized'
+ serialized = @serializer.dump(@packet, :insecure)
+ @serializer.load(serialized, :insecure).should == 'serialized'
end
it "should use the secure serializer if no special format was given" do
View
@@ -2,9 +2,9 @@
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'rubygems'
-require 'spec'
+require 'rspec'
require 'nanite'
-
+
module SpecHelpers
# Initialize logger so it writes to file instead of STDOUT

0 comments on commit 5447466

Please sign in to comment.