Moxy (or moxy
) is a programmable mock proxy. It is an HTTP proxy exposing web hooks that you can use in order to tell it what to do, and when to do it.
Run gem install moxy
$ moxy # no arguments, default to localhost, 9292 $ moxy integration-notifier.dev.com 3000
$ git clone https://github.com/jondot/moxy $ cd moxy; rackup
A web app is great for a dedicated integration server. Moxy will run on any rack handler.
1. Set http://moxy-host:port
as a system proxy, or a proxy in your HTTP library in your code.
2. Issue any number of POSTs to your http://moxy-host:port/__setup__
endpoint with a POST variable named mock_text
.
Below are some examples of mock_text
(in each, second line describes result).
stub_request :get, "http://google.com"
(Returns an empty content with 200
HTTP status code)
stub_request(:get, "http://google.com").to_return(:body => "boo hoo!")
(Returns boo hoo!
as content)
stub_request(:get, "http://google.com").to_return(:body => "boo hoo!", :code => 500)
(Returns boo hoo!
as content)
Moxy can become a very powerful tool for daily tasks or automated testing. Check out moxy at Github for more details and examples.