http_sim - Easy HTTP Simulators
Simulate your external HTTP integrations.
Contributions and issues very welcome.
Standalone usage
- Add
gem 'http_sim'
to yourGemfile
bundle install
Use this code somewhere:
require 'http_sim' HttpSimulator.register_endpoint 'GET', '/hi', '{"some_json": true}' HttpSimulator.register_endpoint 'POST', '/bye', '<html><body>some html</body></html>' HttpSimulator.run!(port:6565)
The endpoints
GET /hi
andPOST /bye
are now set up. Visithttp://localhost:6565/
to see an index of running simulators and their helpers.
Test usage
- Add
gem 'http_sim'
to yourGemfile
bundle install
some_spec.rb
:describe 'some spec' do before :each do HttpSimulator.reset_endpoints HttpSimulator.register_endpoint 'POST', '/some_simulated_endpoint', 'some_simulated_content' HttpSimulator.run_daemon!(port: 6565) end after :each do HttpSimulator.stop_daemon! end it 'does something that needs a simulator backing it' do # your test here end end
Contributing
- Fork it ( https://github.com/[my-github-username]/scaffold/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
)- Please add a test
- Run tests with
bundle install && rspec
- Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request