test/test_app.rb in newark-0.0.6 vs test/test_app.rb in newark-0.0.7

- old
+ new

@@ -1,10 +1,17 @@ require 'helper' class NameApp include Newark + before do + if params[:key] && params[:key] != '23' + response.status = 403 + false + end + end + def upcase(str) str.upcase end get '/upcaser' do @@ -13,20 +20,24 @@ get '/hello1' do hello end + get '/fail' do + 'This should not be reached' + end + get '/hello2', :hello private def hello 'Hello' end end -class TestApp < Minitest::Unit::TestCase +class TestApp < MiniTest::Unit::TestCase include Rack::Test::Methods def app NameApp.new @@ -46,13 +57,13 @@ get '/hello2' assert last_response.ok? assert_equal 'Hello', last_response.body end - # def test_before_hooks_halting_execution - # get '/' - # refute last_response.ok? - # assert_equal 403, last_response.status - # assert_equal '', last_response.body - # end + def test_before_hooks_halting_execution + get '/fail', { key: '1234' } + refute last_response.ok? + assert_equal 403, last_response.status + assert_equal '', last_response.body + end end