Pretender Rails
Stub clientside calls to external services.
Installation
Add this line to your application's Gemfile:
gem 'pretender-rails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pretender-rails
Usage
Cucumber
# features/support/env.rb
require 'pretender/rails/cucumber'
# features/step_definitions/pretender.rb
Given(/^there is a "(.*?)" endpoint$/) do |url|
@stub = stub("get", url, [200, {}, ""])
end
Given(/^that endpoint returns "(.*?)"$/) do |response|
@stub.response = [200, {}, response]
end
In development
Pretender.server.stub('get', 'https://api.github.com/repos/code0100fun/pretender-rails', [200, {}, {name: "mock-repo"}.to_json])
Contributing
- Fork it ( https://github.com/[my-github-username]/pretender-rails/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request