I am using the Koala gem to make facebook requests and i have the following code:
@graph = Koala::Facebook::API.new(oauth_token)
@graph.batch do |batch_api|
#... do stuff here
end
I want to mock out the batch call to simulate the stuff we are doing in there.
Here is what i have in RR.
oauth_token= "Sometoken"
batch_api_mock = nil
graph_mock = mock(Koala::Facebook::API).new(oauth_token).mock!
graph_mock.batch.returns do
yield batch_api_mock if block_given?
end
The problem is that block_given? is return false even though there is a block being passed in my source.
How do i mock a method that takes a block using RR?
K so after looking through the open tickets i found that the answer was that the first argument to the block is a RR::ProcFromBlock which is exactly the block that would be passed to the function. Here is the modification to the code to make it work.
Hope that helps someone save some time. They need to add this little gem to the documentation