A webmock DSL using sinatra.
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib version bump to 1.0.2 Mar 30, 2012
spec
Gemfile
README.md fix README Feb 20, 2012
Rakefile
mocktra.gemspec

README.md

Mocktra

A webmock DSL using sinatra.

Installation

$ gem install mocktra

Examples

require 'mocktra'

# define stub
Mocktra('www.example.com') do
  get '/foo' do
    'FOO!!'
  end

  post '/foo' do
    params.inspect
  end
end

# test it
require 'httpclient'
client = HTTPClient.new

res = client.get("http://www.example.com/foo")
p res.body
#=> "FOO!!"

res = client.post("http://www.example.com/foo", 'bar' => 'baz')
p res.body
#=> "{\"bar\"=>\"baz\"}"

Notice

Mocktra calls WebMock.allow_net_connect! when loading.

Copyright

Copyright (c) 2012 jugyo, released under the MIT license.