Sha256: a99f84fee23724a735dd3c6942d29678daf82e2c85c2608e102875dfe71c0d0a
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
# Mock5 [![Gem Version](https://img.shields.io/gem/v/mock5.svg)][gem] [![Build Status](https://img.shields.io/travis/rwz/mock5.svg)][travis] [![Code Climate](https://img.shields.io/codeclimate/github/rwz/mock5.svg)][codeclimate] [gem]: https://rubygems.org/gems/mock5 [travis]: http://travis-ci.org/rwz/mock5 [codeclimate]: https://codeclimate.com/github/rwz/mock5 Mock5 allows to mock external APIs with simple Sinatra Rake apps. ## Installation Add this line to your application's Gemfile: gem "mock5" And then execute: $ bundle Or install it yourself as: $ gem install mock5 ## Usage ```ruby SuccessfulRegistration = Mock5.mock("http://example.com") do post "/users" do # emulate successful registration MultiJson.dump( first_name: "Zapp", last_name: "Brannigan", email: "zapp@planetexpress.com" ) end end UnsuccessfulRegistration = Mock5.mock("http://example.com") do post "/users" do halt 406, MultiJson.dump( first_name: ["is too lame"], email: ["is not unique"] ) end end describe MyApi do describe "successfull" do around do |example| Mock5.with_mounted SuccessfulRegistration do example.call end end it "allows user registration" do expect{ MyApi.register_user }.not_to raise_error end end describe "validation errors" do around do |example| Mock5.with_mounted UnsuccessfulRegistration do example.call end end it "returns errors" do expect{ MyApi.register_user }.to raise_error(MyApi::ValidationError) end end end ``` ## Contributing 1. Fork it 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mock5-1.0.3 | README.md |
mock5-1.0.2 | README.md |
mock5-1.0.1 | README.md |