|
102 | 102 | request_queue = http.instance_variable_get(:@request_queue) |
103 | 103 | request_attempt = request_queue.deq |
104 | 104 | expect(request_attempt.request).to be_kind_of(Net::HTTP::Post) |
105 | | - expect(request_attempt.request.body).to start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")) |
| 105 | + decompressed_body = Zlib::Inflate.inflate(request_attempt.request.body) |
| 106 | + expect(decompressed_body).to start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")) |
106 | 107 |
|
107 | 108 | message_queue = http.instance_variable_get(:@msg_queue) |
108 | 109 | expect(message_queue.size).to eq(0) |
|
126 | 127 |
|
127 | 128 | it "should deliver requests on an interval" do |
128 | 129 | stub = stub_request(:post, "https://in.logs.betterstack.com/"). |
129 | | - with( |
130 | | - :body => start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")), |
131 | | - :headers => { |
132 | | - 'Authorization' => 'Bearer MYKEY', |
133 | | - 'Content-Type' => 'application/msgpack', |
134 | | - 'User-Agent' => "Logtail Ruby/#{Logtail::VERSION} (HTTP)" |
135 | | - } |
136 | | - ). |
| 130 | + with do |request| |
| 131 | + decompressed_body = Zlib::Inflate.inflate(request.body) |
| 132 | + expect(decompressed_body).to start_with("\x92\x84\xA5level\xA4INFO\xA2dt\xBB2016-09-01T12:00:00.000000Z\xA7message\xB2test log message 1".force_encoding("ASCII-8BIT")) |
| 133 | + |
| 134 | + expect(request.headers['Authorization']).to eq('Bearer MYKEY') |
| 135 | + expect(request.headers['Content-Type']).to eq('application/msgpack') |
| 136 | + expect(request.headers['User-Agent']).to eq("Logtail Ruby/#{Logtail::VERSION} (HTTP)") |
| 137 | + |
| 138 | + true |
| 139 | + end. |
137 | 140 | to_return(:status => 200, :body => "", :headers => {}) |
138 | 141 |
|
139 | 142 | http = described_class.new("MYKEY", flush_interval: 0.1) |
|
0 commit comments