public
Created

extend/include fun

  • Download Gist
fun.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
require './app/app'
 
module StubbedMessaging
Message = Struct.new(:routing_key, :message, :exchange, :type, :options)
 
def publish(routing_key, message, exchange = '', type = :direct, options = {})
message = Message.new(routing_key, message, exchange, type, options)
StubbedMessaging.published_messages << message
end
 
def self.published_messages
@published_messages ||= []
end
end
 
Messaging::Producer.send(:include, StubbedMessaging)
Arms::Remote::Producer.instance.extend(StubbedMessaging)
 
p Arms::Remote::Producer.instance.method(:publish).source_location
 
# => expected
# ["/home/lars/workspace/arms/fun.rb", 6]
# => actual
# ["/home/lars/workspace/arms/lib/messaging/producer.rb", 14]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.