https://github.com/petitviolet/rreplay
HTTP request/response recorder and replayer
https://github.com/petitviolet/rreplay
http-recording rack ruby ruby-gem
Last synced: 22 days ago
JSON representation
HTTP request/response recorder and replayer
- Host: GitHub
- URL: https://github.com/petitviolet/rreplay
- Owner: petitviolet
- License: mit
- Created: 2019-12-27T14:58:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-16T06:10:34.000Z (over 3 years ago)
- Last Synced: 2025-02-01T08:24:40.724Z (over 1 year ago)
- Topics: http-recording, rack, ruby, ruby-gem
- Language: Ruby
- Homepage:
- Size: 1.46 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Rreplay
[](https://badge.fury.io/rb/rreplay)
[](https://github.com/petitviolet/rreplay/actions)
Replay HTTP request and is able to assert if the response is expected.
- Record HTTP request and response into file
- Feed the recorded request and response
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'rreplay'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install rreplay
## Usage
### HTTP request/resopnse recording
Use `Rack::Rreplay`.
In 'config.ru' file:
```ruby
require 'rack/rreplay'
use Rack::Rreplay.Middleware(directory: './rreplay_tmp', format: :json),
{ sample: 5, extra_header_keys: %w[ACCESS_TOKEN], debug: true }
```
This configuration enables rreplay to record HTTP request and response, and write records into `./rreplay_tmp` directory files with specified format(json or msgpack).
Please see the implementation of [rack/rreplay.rb](https://github.com/petitviolet/rreplay/blob/master/lib/rack/rreplay.rb).

### HTTP request replay
Use `bundle exec rreplay ` to send recorded HTTP request in to .
```console
$ bundle exec rreplay 'http://localhost:4567' ./rreplay_tmp/ --format json --verbose
$ bundle exec rreplay 'https://example.com' ./rreplay_tmp/rreplay.log.msgpack --format msgpack
```
Please call `bundle exec rreplay --help` to see arguments and available options.

## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/petitviolet/rreplay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/petitviolet/rreplay/blob/master/CODE_OF_CONDUCT.md).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
Everyone interacting in the Rreplay project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/petitviolet/rreplay/blob/master/CODE_OF_CONDUCT.md).