Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:49:01+00:00 2026-05-26T18:49:01+00:00

I am using the Koala gem to make facebook requests and i have the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:49:02+00:00Added an answer on May 26, 2026 at 6:49 pm

    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.

    oauth_token= "Sometoken"
    batch_api_mock = nil
    graph_mock = mock(Koala::Facebook::API).new(oauth_token).mock!
    
    #The block is passed in as a proc as the first argument to the returns block.
    graph_mock.batch.returns do |proc_as_block|
      proc_as_block.call
    end
    

    Hope that helps someone save some time. They need to add this little gem to the documentation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Koala gem to access the facebook graph api. When I make
I'm using Koala for Facebook Graph API calls and am using a block for
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
I am using the Koala gem to interact with the Facebook API. In order
I am having a rails app and using the Koala gem for the Facebook
I'm using koala to get the following JSON object from facebook: @friends = [{name=>Jolie
Ruby keeps segfaulting when using the Koala gem to talk over HTTP: /Users/pawel/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG]
I am trying to update address/location of a facebook business page through API using
I am newbie in Ruby. I installed by following this tutorial: http://udooz.net/blog/2011/02/facebook-app-using-rails-koala/ Now, when
I am trying to add an app request from a user using Koala/Omniauth @graph

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.