From b7a0c31d713442013a144359c244d3929bd2f2eb Mon Sep 17 00:00:00 2001 From: Dylan Egan Date: Thu, 11 Mar 2010 17:17:56 +1100 Subject: [PATCH] Faqueue, you know it makes sense. --- CONTRIBUTORS.rdoc | 2 +- README.rdoc | 28 +++++------ Rakefile | 10 ++-- lib/{moqueue => faqueue}/fibers18.rb | 0 lib/{moqueue => faqueue}/matchers.rb | 6 +-- lib/{moqueue => faqueue}/mock_broker.rb | 4 +- lib/{moqueue => faqueue}/mock_exchange.rb | 2 +- lib/{moqueue => faqueue}/mock_headers.rb | 4 +- lib/{moqueue => faqueue}/mock_queue.rb | 2 +- lib/{moqueue => faqueue}/object_methods.rb | 6 +-- lib/{moqueue => faqueue}/overloads.rb | 14 +++--- lib/moqueue.rb | 15 ------ spec/examples/ack_spec.rb | 4 +- spec/examples/basic_usage_spec.rb | 8 ++-- spec/examples/logger_spec.rb | 2 +- spec/examples/ping_pong_spec.rb | 4 +- spec/examples/stocks_spec.rb | 4 +- spec/spec_helper.rb | 4 +- spec/unit/matchers_spec.rb | 56 +++++++++++----------- spec/unit/mock_headers_spec.rb | 4 +- spec/unit/mock_queue_spec.rb | 4 +- spec/unit/moqueue_spec.rb | 4 +- spec/unit/object_methods_spec.rb | 6 +-- spec/unit/overloads_spec.rb | 12 ++--- 24 files changed, 95 insertions(+), 110 deletions(-) rename lib/{moqueue => faqueue}/fibers18.rb (100%) rename lib/{moqueue => faqueue}/matchers.rb (98%) rename lib/{moqueue => faqueue}/mock_broker.rb (98%) rename lib/{moqueue => faqueue}/mock_exchange.rb (99%) rename lib/{moqueue => faqueue}/mock_headers.rb (96%) rename lib/{moqueue => faqueue}/mock_queue.rb (99%) rename lib/{moqueue => faqueue}/object_methods.rb (90%) rename lib/{moqueue => faqueue}/overloads.rb (64%) delete mode 100644 lib/moqueue.rb diff --git a/CONTRIBUTORS.rdoc b/CONTRIBUTORS.rdoc index d876c4c..65ad3c5 100644 --- a/CONTRIBUTORS.rdoc +++ b/CONTRIBUTORS.rdoc @@ -1,3 +1,3 @@ = Contributors * larrytheliquid (Larry Diehl) & Engine Yard http://github.com/larrytheliquid -* mattmatt (Mathias Meyer) & Peritor Consulting http://github.com/mattmatt \ No newline at end of file +* mattmatt (Mathias Meyer) & Peritor Consulting http://github.com/mattmatt diff --git a/README.rdoc b/README.rdoc index 7b3cca6..fe0ce18 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,22 +1,22 @@ -= Moqueue -Moqueue is a library for mocking the various objects that make up the ruby AMQP[http://github.com/tmm1/amqp] library. It allows you to use the AMQP library naturally and test your code easily without running an AMQP broker. If you want a higher level of control, you can use your favorite mocking and stubbing library to modify individual calls to MQ.queue and the like so that they return Moqueue's mock up versions. If you want to go all-in, you can tell Moqueue to overload the MQ and AMQP. This allows you to use MQ and AMQP as normal, while Moqueue works behind the scenes to wire everything together. += Faqueue +Faqueue is a library for mocking the various objects that make up the ruby AMQP[http://github.com/tmm1/amqp] library. It allows you to use the AMQP library naturally and test your code easily without running an AMQP broker. If you want a higher level of control, you can use your favorite mocking and stubbing library to modify individual calls to MQ.queue and the like so that they return Faqueue's mock up versions. If you want to go all-in, you can tell Faqueue to overload the MQ and AMQP. This allows you to use MQ and AMQP as normal, while Faqueue works behind the scenes to wire everything together. = Getting started - require "moqueue" + require "faqueue" overload_amqp mq = MQ.new => # queue = mq.queue("mocktacular") - => # + => # topic = mq.topic("lolz") - => # + => # queue.bind(topic, :key=> "cats.*") - => # + => # queue.subscribe {|header, msg| puts [header.routing_key, msg]} => nil @@ -25,10 +25,10 @@ Moqueue is a library for mocking the various objects that make up the ruby AMQP[ # cats.inUrFridge # eatin ur foodz -Note that in this example, we didn't have to deal with AMQP.start or EM.run. This should be ample evidence that you should run higher level tests without any mocks or stubs so you can be sure everything works with real MQ objects. With that said, #overload_amqp does overload the AMQP.start method, so you can use Moqueue for mid-level testing if desired. Have a look at the spec/examples directory to see Moqueue running some of AMQP's examples in overload mode for more demonstration of this. +Note that in this example, we didn't have to deal with AMQP.start or EM.run. This should be ample evidence that you should run higher level tests without any mocks or stubs so you can be sure everything works with real MQ objects. With that said, #overload_amqp does overload the AMQP.start method, so you can use Faqueue for mid-level testing if desired. Have a look at the spec/examples directory to see Faqueue running some of AMQP's examples in overload mode for more demonstration of this. = Custom Rspec Matchers -For Test::Unit users, Moqueue's default syntax should be a good fit with assert(): +For Test::Unit users, Faqueue's default syntax should be a good fit with assert(): assert(queue.received_message?("eatin ur foodz")) Rspec users will probably want something a bit more natural language-y. You got it: queue.should have_received("a message") @@ -39,17 +39,17 @@ As you can tell from the example above, quite a bit is working. This includes di What's not working: * RPC exchanges. -* The routing key matching algorithm works for common cases, including "*" and "#" wildcards in the binding key. If you need anything more complicated than that, Moqueue is not guaranteed to do the right thing. +* The routing key matching algorithm works for common cases, including "*" and "#" wildcards in the binding key. If you need anything more complicated than that, Faqueue is not guaranteed to do the right thing. * Receiving acks when using topic exchanges works only if you subscribe before publishing. -There are some things that Moqueue may never be able to do. As one prominent example, for queues that are configured to expect acknowledgements (the :ack=>true option), the behavior on shutdown is not emulated correctly. +There are some things that Faqueue may never be able to do. As one prominent example, for queues that are configured to expect acknowledgements (the :ack=>true option), the behavior on shutdown is not emulated correctly. == Hacking -Moqueue is at a stage where it "works for me." That said, there may be methods or method signatures that aren't correct/ aren't supported. If this happens to you, fork me and send a pull request when you're done. Patches and feedback welcome. +Faqueue is at a stage where it "works for me." That said, there may be methods or method signatures that aren't correct/ aren't supported. If this happens to you, fork me and send a pull request when you're done. Patches and feedback welcome. == Moar -I wrote an introductory post on my blog, it's probably the best source of high-level discussion right now. Visit: http://kallistec.com/2009/06/21/introducing-moqueue/ +I wrote an introductory post on my blog, it's probably the best source of high-level discussion right now. Visit: http://kallistec.com/2009/06/21/introducing-faqueue/ -If you prefer code over drivel, look at the specs under spec/examples. There you'll find some of the examples from the amqp library running completely Moqueue-ified; the basic_usage_spec.rb shows some lower-level use. +If you prefer code over drivel, look at the specs under spec/examples. There you'll find some of the examples from the amqp library running completely Faqueue-ified; the basic_usage_spec.rb shows some lower-level use. -As always, you're invited to git yer fork on if you want to work on any of these. If you find a bug that you can't source or want to send love or hate mail, you can contact me directly at dan@kallistec.com \ No newline at end of file +As always, you're invited to git yer fork on if you want to work on any of these. If you find a bug that you can't source or want to send love or hate mail, you can contact me directly at dan@kallistec.com diff --git a/Rakefile b/Rakefile index 4d911c9..d7c3828 100644 --- a/Rakefile +++ b/Rakefile @@ -12,14 +12,14 @@ end begin require 'jeweler' Jeweler::Tasks.new do |s| - s.name = "moqueue" + s.name = "faqueue" s.summary = "Mocktacular Companion to AMQP Library. Happy TATFTing!" s.email = "dan@kallistec.com" - s.homepage = "http://github.com/danielsdeleo/moqueue" + s.homepage = "http://github.com/danielsdeleo/faqueue" s.description = "Mocktacular Companion to AMQP Library. Happy TATFTing!" s.authors = ["Daniel DeLeo"] s.files = FileList["[A-Za-z]*", "{lib,spec}/**/*"] - s.rubyforge_project = "moqueue" + s.rubyforge_project = "faqueue" s.add_dependency("amqp") end rescue LoadError @@ -46,7 +46,7 @@ begin ) host = "#{config['username']}@rubyforge.org" - remote_dir = "/var/www/gforge-projects/moqueue/" + remote_dir = "/var/www/gforge-projects/faqueue/" local_dir = 'rdoc' Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload @@ -61,4 +61,4 @@ Rake::RDocTask.new do |rd| rd.main = "README.rdoc" rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") rd.rdoc_dir = "rdoc" -end \ No newline at end of file +end diff --git a/lib/moqueue/fibers18.rb b/lib/faqueue/fibers18.rb similarity index 100% rename from lib/moqueue/fibers18.rb rename to lib/faqueue/fibers18.rb diff --git a/lib/moqueue/matchers.rb b/lib/faqueue/matchers.rb similarity index 98% rename from lib/moqueue/matchers.rb rename to lib/faqueue/matchers.rb index fab5229..4abb8e3 100644 --- a/lib/moqueue/matchers.rb +++ b/lib/faqueue/matchers.rb @@ -1,4 +1,4 @@ -module Moqueue +module Faqueue module Matchers class HasReceived @@ -108,6 +108,6 @@ def have_received_exact_routing_key(expected_key) if defined?(::Spec::Runner) Spec::Runner.configure do |config| - config.include(::Moqueue::Matchers) + config.include(::Faqueue::Matchers) end -end \ No newline at end of file +end diff --git a/lib/moqueue/mock_broker.rb b/lib/faqueue/mock_broker.rb similarity index 98% rename from lib/moqueue/mock_broker.rb rename to lib/faqueue/mock_broker.rb index 48477ce..5694d53 100644 --- a/lib/moqueue/mock_broker.rb +++ b/lib/faqueue/mock_broker.rb @@ -1,6 +1,6 @@ require "singleton" -module Moqueue +module Faqueue class MockBroker include Singleton @@ -50,4 +50,4 @@ def find_fanout_exchange(fanout_name) end end -end \ No newline at end of file +end diff --git a/lib/moqueue/mock_exchange.rb b/lib/faqueue/mock_exchange.rb similarity index 99% rename from lib/moqueue/mock_exchange.rb rename to lib/faqueue/mock_exchange.rb index c0d36b0..4d1fd13 100644 --- a/lib/moqueue/mock_exchange.rb +++ b/lib/faqueue/mock_exchange.rb @@ -1,4 +1,4 @@ -module Moqueue +module Faqueue class MockExchange attr_reader :topic, :fanout, :direct diff --git a/lib/moqueue/mock_headers.rb b/lib/faqueue/mock_headers.rb similarity index 96% rename from lib/moqueue/mock_headers.rb rename to lib/faqueue/mock_headers.rb index 78b6835..0ae52fb 100644 --- a/lib/moqueue/mock_headers.rb +++ b/lib/faqueue/mock_headers.rb @@ -1,4 +1,4 @@ -module Moqueue +module Faqueue class MockHeaders attr_accessor :size, :weight @@ -28,4 +28,4 @@ def method_missing method, *args, &blk end end -end \ No newline at end of file +end diff --git a/lib/moqueue/mock_queue.rb b/lib/faqueue/mock_queue.rb similarity index 99% rename from lib/moqueue/mock_queue.rb rename to lib/faqueue/mock_queue.rb index bea053e..f068e35 100644 --- a/lib/moqueue/mock_queue.rb +++ b/lib/faqueue/mock_queue.rb @@ -1,4 +1,4 @@ -module Moqueue +module Faqueue class DoubleSubscribeError < StandardError end diff --git a/lib/moqueue/object_methods.rb b/lib/faqueue/object_methods.rb similarity index 90% rename from lib/moqueue/object_methods.rb rename to lib/faqueue/object_methods.rb index f882673..981a725 100644 --- a/lib/moqueue/object_methods.rb +++ b/lib/faqueue/object_methods.rb @@ -1,4 +1,4 @@ -module Moqueue +module Faqueue module ObjectMethods def mock_queue_and_exchange(name=nil) @@ -25,7 +25,7 @@ def mock_exchange(opts={}) # Overloads the class-level method calls typically used by AMQP code # such as MQ.direct, MQ.queue, MQ.topic, etc. def overload_amqp - require MOQUEUE_ROOT + "moqueue/overloads" + require FAQUEUE_ROOT + "faqueue/overloads" end # Deletes all exchanges and queues from the mock broker. As a consequence of @@ -38,4 +38,4 @@ def reset_broker end -Object.send(:include, Moqueue::ObjectMethods) \ No newline at end of file +Object.send(:include, Faqueue::ObjectMethods) diff --git a/lib/moqueue/overloads.rb b/lib/faqueue/overloads.rb similarity index 64% rename from lib/moqueue/overloads.rb rename to lib/faqueue/overloads.rb index 3e40593..2b654a2 100644 --- a/lib/moqueue/overloads.rb +++ b/lib/faqueue/overloads.rb @@ -4,15 +4,15 @@ class MQ class << self def queue(name) - Moqueue::MockQueue.new(name) + Faqueue::MockQueue.new(name) end def direct(name, opts={}) - Moqueue::MockExchange.new(opts.merge(:direct=>name)) + Faqueue::MockExchange.new(opts.merge(:direct=>name)) end def fanout(name, opts={}) - Moqueue::MockExchange.new(opts.merge(:fanout=>name)) + Faqueue::MockExchange.new(opts.merge(:fanout=>name)) end end @@ -21,19 +21,19 @@ def initialize(*args) end def direct(name, opts = {}) - Moqueue::MockExchange.new(opts.merge(:direct => name)) + Faqueue::MockExchange.new(opts.merge(:direct => name)) end def fanout(name, opts = {}) - Moqueue::MockExchange.new(opts.merge(:fanout => name)) + Faqueue::MockExchange.new(opts.merge(:fanout => name)) end def queue(name, opts = {}) - Moqueue::MockQueue.new(name) + Faqueue::MockQueue.new(name) end def topic(topic_name) - Moqueue::MockExchange.new(:topic=>topic_name) + Faqueue::MockExchange.new(:topic=>topic_name) end end diff --git a/lib/moqueue.rb b/lib/moqueue.rb deleted file mode 100644 index 4ca06d8..0000000 --- a/lib/moqueue.rb +++ /dev/null @@ -1,15 +0,0 @@ -unless defined?(MOQUEUE_ROOT) - MOQUEUE_ROOT = File.dirname(__FILE__) + "/" -end -require MOQUEUE_ROOT + "moqueue/fibers18" - -require MOQUEUE_ROOT + "moqueue/mock_exchange" -require MOQUEUE_ROOT + "moqueue/mock_queue" -require MOQUEUE_ROOT + "moqueue/mock_headers" -require MOQUEUE_ROOT + "moqueue/mock_broker" - -require MOQUEUE_ROOT + "moqueue/object_methods" -require MOQUEUE_ROOT + "moqueue/matchers" - -module Moqueue -end \ No newline at end of file diff --git a/spec/examples/ack_spec.rb b/spec/examples/ack_spec.rb index 8ce223c..072843f 100644 --- a/spec/examples/ack_spec.rb +++ b/spec/examples/ack_spec.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/example_helper' -# NOTE: moqueue currently does not mimic AMQP's behavior of: +# NOTE: faqueue currently does not mimic AMQP's behavior of: # 1) requiring graceful shutdown for acks to be delivered # 2) returning messages to the queue if not acked # 3) not processing messages when AMQP isn't "running" @@ -10,7 +10,7 @@ # with a real broker. The true behavior should be that the 3rd message # published should be unacknowledged and returned to the queue. In this test, # all messages get acknowleged -describe Moqueue, "when running the ack example" do +describe Faqueue, "when running the ack example" do include ExampleHelper def run_ack_example(&perform_ack) diff --git a/spec/examples/basic_usage_spec.rb b/spec/examples/basic_usage_spec.rb index c19ed6f..f43243b 100644 --- a/spec/examples/basic_usage_spec.rb +++ b/spec/examples/basic_usage_spec.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe "AMQP", "when mocked out by Moqueue" do +describe "AMQP", "when mocked out by Faqueue" do before(:each) do reset_broker @@ -54,7 +54,7 @@ end -describe Moqueue, "with syntax sugar" do +describe Faqueue, "with syntax sugar" do before(:each) do reset_broker @@ -82,7 +82,7 @@ end -describe Moqueue, "when using custom rspec matchers" do +describe Faqueue, "when using custom rspec matchers" do it "should accept syntax like queue.should have_received('a message')" do queue = mock_queue("sugary") @@ -98,4 +98,4 @@ queue.should have_ack_for("another message") end -end \ No newline at end of file +end diff --git a/spec/examples/logger_spec.rb b/spec/examples/logger_spec.rb index 9e71f15..b824b82 100644 --- a/spec/examples/logger_spec.rb +++ b/spec/examples/logger_spec.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe Moqueue, "when running the logger example" do +describe Faqueue, "when running the logger example" do class MyLoggerRulez def initialize *args, &block diff --git a/spec/examples/ping_pong_spec.rb b/spec/examples/ping_pong_spec.rb index 8026435..709b0f2 100644 --- a/spec/examples/ping_pong_spec.rb +++ b/spec/examples/ping_pong_spec.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/example_helper' -describe Moqueue, "when testing the ping pong example" do +describe Faqueue, "when testing the ping pong example" do include ExampleHelper def ping_pong @@ -47,4 +47,4 @@ def ping_pong [2, :sending, "ping"], [2, "one", :received, "ping", :sending, "pong"], [2, "two", :received, "pong"]] @captured_output.should == expected end -end \ No newline at end of file +end diff --git a/spec/examples/stocks_spec.rb b/spec/examples/stocks_spec.rb index 856d0af..3d87475 100644 --- a/spec/examples/stocks_spec.rb +++ b/spec/examples/stocks_spec.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/example_helper' -describe Moqueue, "when running the stocks example" do +describe Faqueue, "when running the stocks example" do include ExampleHelper def run_stocks @@ -61,4 +61,4 @@ def watch_us_stocks @apple_queue.should have(6).received_messages end -end \ No newline at end of file +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 00cf47c..9da5699 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,7 +5,7 @@ config.mock_with :mocha end -require File.dirname(__FILE__) + "/../lib/moqueue" +require File.dirname(__FILE__) + "/../lib/faqueue" # Make sure tests fail if deferred blocks (for susbscribe and pop) don't get called def ensure_deferred_block_called(opts={:times=>1}) @@ -23,4 +23,4 @@ def ensure_deferred_block_skipped @skip_me.expects(:deferred_block_called).times(0) end -include Moqueue \ No newline at end of file +include Faqueue diff --git a/spec/unit/matchers_spec.rb b/spec/unit/matchers_spec.rb index 761c370..076bc55 100644 --- a/spec/unit/matchers_spec.rb +++ b/spec/unit/matchers_spec.rb @@ -2,50 +2,50 @@ describe Matchers do class MatcherHarness - include Moqueue::Matchers + include Faqueue::Matchers end before(:each) do @matchable = MatcherHarness.new - @mock_moqueue = mock("mock Moqueue::MockQueue") + @mock_faqueue = mock("mock Faqueue::MockQueue") @failure_exception = Spec::Expectations::ExpectationNotMetError end it "should include matchers in describe blocks automatically when using rspec" do - self.class.include?(Moqueue::Matchers).should be_true + self.class.include?(Faqueue::Matchers).should be_true end it "should implement Object#should have_received_message" do - @mock_moqueue.expects(:received_message?).with("matchtacular").returns(true) - @mock_moqueue.should have_received_message("matchtacular") + @mock_faqueue.expects(:received_message?).with("matchtacular").returns(true) + @mock_faqueue.should have_received_message("matchtacular") end it "should implement Object#should_not have_received_message" do - @mock_moqueue.expects(:received_message?).with("no match").returns(false) - @mock_moqueue.should_not have_received_message("no match") + @mock_faqueue.expects(:received_message?).with("no match").returns(false) + @mock_faqueue.should_not have_received_message("no match") end it "should implement Object#should have_exact_routing_key(key)" do - @mock_moqueue.expects(:received_routing_key?).with("routing.key").returns(true) - @mock_moqueue.should have_received_exact_routing_key("routing.key") + @mock_faqueue.expects(:received_routing_key?).with("routing.key").returns(true) + @mock_faqueue.should have_received_exact_routing_key("routing.key") end it "should implement Object#should_not have_exact_routing_key(key)" do - @mock_moqueue.expects(:received_routing_key?).with("routing.key").returns(false) - @mock_moqueue.should_not have_received_exact_routing_key("routing.key") + @mock_faqueue.expects(:received_routing_key?).with("routing.key").returns(false) + @mock_faqueue.should_not have_received_exact_routing_key("routing.key") end it "should have a useful failure message" do - @mock_moqueue.expects(:received_message?).with("this fails").returns(false) - failing_example = lambda {@mock_moqueue.should have_received_message("this fails")} - error_message = "expected #{@mock_moqueue.inspect} to have received message ``this fails''" + @mock_faqueue.expects(:received_message?).with("this fails").returns(false) + failing_example = lambda {@mock_faqueue.should have_received_message("this fails")} + error_message = "expected #{@mock_faqueue.inspect} to have received message ``this fails''" failing_example.should raise_error(@failure_exception, error_message) end it "should have a useful negative failure message" do - @mock_moqueue.expects(:received_message?).with("FAIL").returns(true) - failing_example = lambda{@mock_moqueue.should_not have_received_message("FAIL")} - error_message = "expected #{@mock_moqueue.inspect} to not have received message ``FAIL''" + @mock_faqueue.expects(:received_message?).with("FAIL").returns(true) + failing_example = lambda{@mock_faqueue.should_not have_received_message("FAIL")} + error_message = "expected #{@mock_faqueue.inspect} to not have received message ``FAIL''" failing_example.should raise_error(@failure_exception, error_message) end @@ -67,26 +67,26 @@ class MatcherHarness end it "should implement Object#should have_received_ack_for(msg_text)" do - @mock_moqueue.expects(:received_ack_for_message?).with("foo bar").returns(true) - @mock_moqueue.should have_received_ack_for("foo bar") + @mock_faqueue.expects(:received_ack_for_message?).with("foo bar").returns(true) + @mock_faqueue.should have_received_ack_for("foo bar") end it "should implement Object#should_not have_received_ack_for(msg_text)" do - @mock_moqueue.expects(:received_ack_for_message?).with("bar baz").returns(false) - @mock_moqueue.should_not have_received_ack_for("bar baz") + @mock_faqueue.expects(:received_ack_for_message?).with("bar baz").returns(false) + @mock_faqueue.should_not have_received_ack_for("bar baz") end it "should have a helpful failure message" do - @mock_moqueue.expects(:received_ack_for_message?).with("foo baz").returns(false) - failure = lambda {@mock_moqueue.should have_received_ack_for("foo baz")} - fail_msg = "expected #{@mock_moqueue.inspect} to have received an ack for the message ``foo baz''" + @mock_faqueue.expects(:received_ack_for_message?).with("foo baz").returns(false) + failure = lambda {@mock_faqueue.should have_received_ack_for("foo baz")} + fail_msg = "expected #{@mock_faqueue.inspect} to have received an ack for the message ``foo baz''" failure.should raise_error(@failure_exception, fail_msg) end it "should have a helpful negative failure message" do - @mock_moqueue.expects(:received_ack_for_message?).with("bar foo").returns(true) - failure = lambda {@mock_moqueue.should_not have_received_ack_for("bar foo")} - fail_msg = "expected #{@mock_moqueue.inspect} to not have received an ack for the message ``bar foo''" + @mock_faqueue.expects(:received_ack_for_message?).with("bar foo").returns(true) + failure = lambda {@mock_faqueue.should_not have_received_ack_for("bar foo")} + fail_msg = "expected #{@mock_faqueue.inspect} to not have received an ack for the message ``bar foo''" failure.should raise_error(@failure_exception, fail_msg) end @@ -99,4 +99,4 @@ class MatcherHarness e.message.should match(/you can't use \`\`should have_received_message\'\' on #\ "sweetSugar").should be_kind_of(Moqueue::MockExchange) + mock_exchange(:topic => "sweetSugar").should be_kind_of(Faqueue::MockExchange) end -end \ No newline at end of file +end diff --git a/spec/unit/overloads_spec.rb b/spec/unit/overloads_spec.rb index eab82b5..26e4702 100644 --- a/spec/unit/overloads_spec.rb +++ b/spec/unit/overloads_spec.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/../spec_helper' -describe "AMQP and MQ", "when overloaded by moqueue/overloads" do +describe "AMQP and MQ", "when overloaded by faqueue/overloads" do before(:all) do overload_amqp @@ -20,7 +20,7 @@ end it "should provide a MQ.queue class method" do - MQ.queue('FTW').should be_a(Moqueue::MockQueue) + MQ.queue('FTW').should be_a(Faqueue::MockQueue) end it "should emulate the behavior of MQ.closing?" do @@ -40,17 +40,17 @@ end it "should provide a MQ.direct class method" do - MQ.direct("direct", :durable=>true).should be_a(Moqueue::MockExchange) + MQ.direct("direct", :durable=>true).should be_a(Faqueue::MockExchange) end it "should provide a MQ.fanout class method" do - MQ.fanout("fanout", :durable=>true).should be_a(Moqueue::MockExchange) + MQ.fanout("fanout", :durable=>true).should be_a(Faqueue::MockExchange) end it "should create a named fanout queue via MQ.fanout" do fanout = MQ.fanout("SayMyNameSayMyName", :durable=>true) - fanout.should be_a(Moqueue::MockExchange) + fanout.should be_a(Faqueue::MockExchange) fanout.fanout.should == "SayMyNameSayMyName" end -end \ No newline at end of file +end