Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Generating fake responses by caching real ones once first.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ben Marini  
View profile  
 More options Jun 21 2010, 10:47 pm
From: Ben Marini <bmar...@gmail.com>
Date: Mon, 21 Jun 2010 19:47:55 -0700 (PDT)
Local: Mon, Jun 21 2010 10:47 pm
Subject: Generating fake responses by caching real ones once first.
I have a third party API that I'd like to mock with FakeWeb, but I was
hoping FakeWeb could generate the mocked responses for me the first
time around. What I want would be something like this:

    # Setup some type of caching for the request responses, for
example:
    CACHE = ActiveSupport::Cache::FileStore.new "test/fixtures/api/"

    # If passed a block, yields the method, normalized uri, and
    # Net::Http request object
    FakeWeb.register_uri(:all, /.*/) do |method, uri, request|
      CACHE.fetch(uri) do
         # Forces a real request through by temporarily allowing a net
request
        FakeWeb.force(request)
      end
    end

This way I could easily generate the right mock responses for the
requests I make, and then manually tweak them in the "fixture" or
cache file.

Has anyone done something like this already? I'd like to implement
this but want a second opinion since I'm new to this gem.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »