Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created February 19, 2010 21:44
Show Gist options
  • Select an option

  • Save hayeah/309249 to your computer and use it in GitHub Desktop.

Select an option

Save hayeah/309249 to your computer and use it in GitHub Desktop.
def pop(opts={})
queue.pop(opts) do |header,payload|
donkey.process(header,Donkey::Message.decode(payload))
end
end
# Public#pop
it "pops a message" do
header = "header"
payload = "payload"
queue = Object.new
class << queue
attr_reader :captured_block
def pop(opts,&block)
@captured_block = block
end
end
# mocks the object we are testing to return the queue double
mock(@public).queue { queue }
mock(Donkey::Message).decode(payload) { "message" }
mock(@donkey).process(header,"message")
@public.pop
# tests the call back
queue.captured_block.call(header,payload)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment