forked from airbrake/airbrake
/
user_informer_test.rb
29 lines (23 loc) · 942 Bytes
/
user_informer_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require File.dirname(__FILE__) + '/helper'
class UserInformerTest < Test::Unit::TestCase
should "modify output if there is an airbrake id" do
main_app = lambda do |env|
env['airbrake.error_id'] = 1
[200, {}, ["<!-- AIRBRAKE ERROR -->"]]
end
informer_app = Airbrake::UserInformer.new(main_app)
ShamRack.mount(informer_app, "example.com")
response = Net::HTTP.get_response(URI.parse("http://example.com/"))
assert_equal "Airbrake Error 1", response.body
assert_equal 16, response["Content-Length"].to_i
end
should "not modify output if there is no airbrake id" do
main_app = lambda do |env|
[200, {}, ["<!-- AIRBRAKE ERROR -->"]]
end
informer_app = Airbrake::UserInformer.new(main_app)
ShamRack.mount(informer_app, "example.com")
response = Net::HTTP.get_response(URI.parse("http://example.com/"))
assert_equal "<!-- AIRBRAKE ERROR -->", response.body
end
end