Sha256: 97062858366ec12bb54cb636781bd031c6ea538fdc4e954997c2ed35e552b0da
Contents?: true
Size: 950 Bytes
Versions: 2
Compression:
Stored size: 950 Bytes
Contents
require 'minitest_helper' describe Rasti::Web::Router do let(:router) { Rasti::Web::Router.new } def get(path) Rack::MockRequest.env_for path, method: :get end def post(path) Rack::MockRequest.env_for path, method: :post end it 'Verbs' do %w(delete get head options patch post put).each do |verb| router.must_respond_to verb end end it 'Route matching' do router.get '/resources', ->(env) { :index } router.post '/resources/:id', ->(env) { :update } router.not_found ->(env) { :not_found } router.call(get('/resources')).must_equal :index router.call(post('/resources/123')).must_equal :update router.call(post('/resources')).must_equal :not_found end it 'Not found' do status, headers, response = router.call get('/not_found') status.must_equal 404 headers.must_equal 'Content-Length' => '25' response.body.must_equal ['Not found: GET /not_found'] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rasti-web-2.1.1 | spec/router_spec.rb |
rasti-web-2.1.0 | spec/router_spec.rb |