Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A webmock DSL using sinatra.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 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.

Something went wrong with that request. Please try again.