test/test_rewrite.rb in jellyfish-1.2.2 vs test/test_rewrite.rb in jellyfish-1.3.0

- old
+ new

@@ -3,11 +3,13 @@ require 'jellyfish/urlmap' describe Jellyfish::Rewrite do paste :jellyfish - lam = lambda{ |env| [200, {}, [env['PATH_INFO']]] } + lam = lambda do |env| + [200, {}, ["#{env['SCRIPT_NAME']}!#{env['PATH_INFO']}"]] + end def call app, path get(path, app).dig(-1, 0) end @@ -16,25 +18,27 @@ map '/from', to: '/to' do run lam end end - expect(call(app, '/from/here')).eq '/to/here' + expect(call(app, '/from/here')).eq '!/to/here' end would 'rewrite and fallback' do app = Jellyfish::Builder.app do - rewrite '/from/inner' => '/to/inner', - '/from/outer' => '/to/outer' do - run lam - end + map '/top' do + rewrite '/from/inner' => '/to/inner', + '/from/outer' => '/to/outer' do + run lam + end - map '/from' do - run lam + map '/from' do + run lam + end end end - expect(call(app, '/from' )).eq '' - expect(call(app, '/from/inner')).eq '/to/inner' - expect(call(app, '/from/outer')).eq '/to/outer' + expect(call(app, '/top/from/other')).eq '/top/from!/other' + expect(call(app, '/top/from/inner')).eq '/top!/to/inner' + expect(call(app, '/top/from/outer')).eq '/top!/to/outer' end end