test/angelo/eventsource_spec.rb in angelo-0.1.23 vs test/angelo/eventsource_spec.rb in angelo-0.1.24

- old
+ new

@@ -48,25 +48,41 @@ describe 'error handling' do define_app do - before do + before '/msg' do raise 'wrong' end + before '/other' do + raise Angelo::RequestError.new sse_message('foo'), 200 + end + eventsource '/msg' do |c| c.write sse_message 'hi' c.close end + eventsource '/other' do |c| + c.write sse_message 'other' + c.close + end + end it 'handles exceptions in before blocks' do get_sse '/msg' do |msg| msg.must_equal "wrong" end last_response.status.must_equal 500 + end + + it 'handles RequestError exceptions in before blocks' do + get_sse '/other' do |msg| + msg.must_equal "data: foo\n\n" + end + last_response.status.must_equal 200 end end end