Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,39 @@ A webmock DSL using sinatra.
Installation
----

$ gem install mocktra
```bash
$ gem install mocktra
```

Examples
----

require 'mocktra'
```ruby
require 'mocktra'

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

post '/foo' do
params.inspect
end
end
post '/foo' do
params.inspect
end
end

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

res = client.get("http://www.example.com/foo")
p res.body
#=> "FOO!!"
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\"}"
res = client.post("http://www.example.com/foo", 'bar' => 'baz')
p res.body
#=> "{\"bar\"=>\"baz\"}"
```

Notice
----
Expand All @@ -44,4 +48,4 @@ Mocktra calls `WebMock.allow_net_connect!` when loading.
Copyright
----

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