lib/fluffle/testing.rb in fluffle-0.1.1 vs lib/fluffle/testing.rb in fluffle-0.2.0
- old
+ new
@@ -1,9 +1,23 @@
require 'concurrent'
module Fluffle
module Testing
+ def self.setup!
+ # Inject our own custom `Connectable` implementation
+ [Fluffle::Client, Fluffle::Server].each do |mod|
+ mod.include Connectable
+ end
+
+ Fluffle::Server.class_eval do
+ # Overwriting this so that we don't actually block waiting for signal
+ def wait_for_signal
+ # pass
+ end
+ end
+ end
+
# Patch in a new `#connect` method that injects the loopback
module Connectable
def self.included(klass)
klass.class_eval do
alias_method :original_connect, :connect
@@ -13,16 +27,10 @@
end
end
end
end
- def self.inject_connectable
- [Fluffle::Client, Fluffle::Server].each do |mod|
- mod.include Connectable
- end
- end
-
# Fake RabbitMQ server presented through a subset of the `Bunny`
# library's interface
class Loopback
# Singleton server instance that lives in the process
def self.instance
@@ -117,16 +125,10 @@
def subscribe(&block)
@server.add_queue_subscriber @name, block
end
end
- class WorkPool
- # No-op in testing
- def join
- end
- end
-
end # class LoopbackServer
end # module Testing
end # module Fluffle
-Fluffle::Testing.inject_connectable
+Fluffle::Testing.setup!