InspectRequest

This library will provide you with a proxy (Ritm) which make it possible to inspect network going thru it. It similar to what mockserver provide, but much simpler (less feature as well). Under the verification function, you have a copy of the request. And you can inspect it however you want. In the end, you just need to return true/false.

Default port is 7777. You cannot change it yet.

Installation

Add this line to your application's Gemfile:

gem 'inspect_request'

And then execute:

$ bundle

Or install it yourself as:

$ gem install inspect_request

Usage

require 'inspect_request'
require 'rest-client'

foo = InspectRequest::Checker.new

# we can configure our proxy details similar to Ritm
foo.configure do
    proxy[:bind_port] = 7777 # default port
end

foo.verify do |req|
    req.host == 'example.org'
end

# make sure to go throuh our proxy
RestClient.proxy = 'http://127.0.0.1:7777'
# send a test request
RestClient.get 'http://example.org'

sleep 1
foo.fulfilled? # true

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/umbrella.

License

The gem is available as open source under the terms of the MIT License.