github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mdub / sham_rack

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 28
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (2)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (2)
    • v1.2.1
    • v1.0.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

run Rack applications in-process, without a server — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Regenerated gemspec for version 1.2.1 
mdub (author)
Fri Jan 15 03:37:53 -0800 2010
commit  2a479d572e5230962f157d4d7e6caeb6d7d046f4
tree    9175b3864ea9357adb9c39660532011189a2493f
parent  da43a0314de7123764be65988d7bcde0458b659f
sham_rack /
name age
history
message
file .gitignore Wed Jun 03 04:20:50 -0700 2009 Prep for Rubyforge release. [mdub]
file CHANGES.markdown Fri Jan 15 03:34:26 -0800 2010 Credit jrun in the change-log. [mdub]
file README.markdown Fri Nov 27 04:38:02 -0800 2009 Update doco. [mdub]
file Rakefile Fri Jan 15 01:31:37 -0800 2010 Remove unnecessary loading of non-existant VERS... [mdub]
directory benchmark/ Sat Jun 27 05:05:33 -0700 2009 Compare performance of ShamRack vs running a Ra... [mdub]
directory lib/ Sat Jan 09 08:32:19 -0800 2010 bump version and update gemspec so i can gem bu... [Jeremy Burks]
file sham_rack.gemspec Fri Jan 15 03:37:53 -0800 2010 Regenerated gemspec for version 1.2.1 [mdub]
directory spec/ Fri Nov 27 01:24:18 -0800 2009 Rather than trying to duck-type Net::HTTP, I'll... [mdub]
README.markdown

ShamRack

ShamRack plumbs Net:HTTP into Rack.

What's it for, again?

Well, it makes it easy to stub out external (HTTP) services, which is handy in development and testing environments, or when you want to test your HTTP client code.

You can also use it to test your Rack application (or Sinatra, or Rails, or Merb) using arbitrary HTTP client libraries, to check interoperability. For instance, you could test your app using:

  • rest-client
  • httparty
  • oauth

all without having to boot it in a server.

Installing it

gem install sham_rack

Using it

A simple inline application

require 'sham_rack'

ShamRack.at("www.example.com") do |env|
  ["200 OK", { "Content-type" => "text/plain" }, "Hello, world!"]
end

require 'open-uri'
open("http://www.example.com/").read            #=> "Hello, world!"

Sinatra integration

ShamRack.at("sinatra.xyz").sinatra do
  get "/hello/:subject" do
    "Hello, #{params[:subject]}"
  end
end

open("http://sinatra.xyz/hello/stranger").read  #=> "Hello, stranger"

Rackup support

ShamRack.at("rackup.xyz").rackup do
  use Some::Middleware
  use Some::Other::Middleware
  run MyApp.new
end

Any old app

ShamRack.mount(my_google_stub, "google.com")

What's the catch?

  • Your Rack request-handling code runs in the same Ruby VM, in fact the same Thread, as your request.

Thanks to

  • Blaine Cook for FakeWeb, which was an inspiration for ShamRack.
  • Perryn Fowler for his efforts plumbing Net::HTTP into ActionController::TestProcess.
  • Christian Neukirchen et al for the chewy goodness that is Rack.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server