Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rack::ClientSpec

Harukasan
November 17, 2014

 Rack::ClientSpec

Rack::ClientSpec can test your client behavior
社内勉強会用資料

Harukasan

November 17, 2014
Tweet

More Decks by Harukasan

Other Decks in Technology

Transcript

  1. Insert ClientSpec to your rack Server Client send a response

    (if you need) get a request ClientSpec
  2. Insert ClientSpec to your rack app require 'rack' require 'rack/lobster'

    require 'rack/client_spec' require 'rack/lobster_spec' use Rack::ClientSpec, LobsterSpec # <- Insert Clientspec run Rack::Lobster.new
  3. Write a test case require 'rack/client_spec' class LobsterSpec < Rack::ClientSpec::TestCase

    # <-- test case def test_flip # <-- test method get '/' do |req, res| # <-- expect request assert { res.status == 200 } end get '/?flip=left' do |req, res| # <-- expect request assert { req['HTTP_REFERER'] == 'http://localhost:9292/' } end end end