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
API changes to support request bodies
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
 
Chris Kampmeier  
View profile  
 More options Jan 25 2009, 5:19 pm
From: Chris Kampmeier <ChrisGKampme...@gmail.com>
Date: Sun, 25 Jan 2009 14:19:48 -0800 (PST)
Local: Sun, Jan 25 2009 5:19 pm
Subject: API changes to support request bodies
(crossposted from the Lighthouse account)

The last feature to add to FakeWeb before you could completely stub
out a RESTful web service is the ability to respond to PUTs and POSTs
differently depending on the content of their request bodies.

I already extended FakeWeb to support HTTP methods, which got us here:

    FakeWeb.register_uri(:get, "http://example.com", :string =>
"response")

It'd be natural to just add a third parameter before the options hash:

    FakeWeb.register_uri(:post, "http://example.com/users", "user
[login]=chrisk", :string => "User chrisk created!")

Something that's attractive to me about Ruby, though, is the way that
keys in options hashes make method calls self-documenting. In
practice, having many parameters (4, here) often strikes me as a code
smell of a method that needs refactoring. So something more like this
would be easier to understand, at a glance:

    FakeWeb.register_uri(:post, "http://example.com/users", :body =>
"user[login]=chrisk", :string => "User chrisk created!")

However, we're currently using the third argument for only the
response, not the request -- it might more accurately be called
`response_options`. And that'll be parsed as one options hash with two
keys. So that gets confusing.

One solution would be to get all RSpecky:

    FakeWeb.register(:post, "http://example.com/users").with_body("user
[login]=chrisk").and_respond(:string => "User chrisk created!")

Something like that would be kind of nice, actually. That'd require
some major architectural changes to FakeWeb, though.

Anybody have thoughts or suggestions? I wanted to get this out in the
open instead of just thinking about it by myself.

Thanks,
Chris


 
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