Created
February 19, 2010 21:44
-
-
Save hayeah/309249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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