Skip to content
This repository

ww(Double Web)

ww(Double Web) is a framework to build double Web server.

It helps building double (Stub, Mock, Spy) Web server using Sinatra.

about ‘test double’, see the xunitpatterns.com articles.

`ww’ enables you to

  • build Double build HTTP server. This is useful, for example, testing with 3rd party API server.
  • launch server from unit test, and reset the server per testcase.
  • define actions using Sinatra API. (Stub)
  • collect requests and access them for validation from your test. (Spy)
  • expect and verify the access from app. (Mock)
  • see collect requests from your app to the double server. (Spy by your Eye)

Planning features.

see GitHub Issues

Installation

gem install ww

Synopsis

Ww::Server

here is the sample code to use Spy::Server from unit test.

see http://github.com/moro/ww/blob/master/spec/ww/server_integration_spec.rb

Ww::SpyEye

build spy server. (in example/spy_eye.ru)

require 'ww/spy_eye'

app = Ww::SpyEye.to_app do
  spy(:get, "/hello") do
    "Hello World"
  end

  spy(:post, "/hello") do
    redirect "/hello"
  end
end

run app

and run commands below;

 $ rackup -p 8888 example/spy_eye.ru
 $ curl http://localhost:8888/hello
 $ curl -d key=1st -d message='KON-NICHIWA'  http://localhost:8888/hello
 $ curl -d key=2nd -d message='How are you?' http://localhost:8888/hello
 $ open http://localhost:8888/spy # or any browser.

You’ll get collected requests.

see output sample at http://github.com/moro/ww/raw/master/example/spy_eye_output.html

Acknowledgements

ww’s development has been supported by Eiwa System Management,Inc.

License

Copyright (c) 2009-2010 MOROHASHI Kyosuke

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.