Sha256: 9bf6f4998d506f52fe4baa28ee3df0d0165dc32343662e84c671b276e101f081
Contents?: true
Size: 904 Bytes
Versions: 13
Compression:
Stored size: 904 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 response.body.must_equal ['Not found: GET /not_found'] end end
Version data entries
13 entries across 13 versions & 1 rubygems