httparty 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of httparty might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/Gemfile +1 -0
- data/httparty.gemspec +0 -1
- data/lib/httparty.rb +2 -18
- data/lib/httparty/connection_adapter.rb +10 -0
- data/lib/httparty/headers_processor.rb +30 -0
- data/lib/httparty/request.rb +4 -4
- data/lib/httparty/version.rb +1 -1
- metadata +4 -103
- data/features/basic_authentication.feature +0 -20
- data/features/command_line.feature +0 -95
- data/features/deals_with_http_error_codes.feature +0 -26
- data/features/digest_authentication.feature +0 -30
- data/features/handles_compressed_responses.feature +0 -27
- data/features/handles_multiple_formats.feature +0 -57
- data/features/steps/env.rb +0 -27
- data/features/steps/httparty_response_steps.rb +0 -56
- data/features/steps/httparty_steps.rb +0 -43
- data/features/steps/mongrel_helper.rb +0 -127
- data/features/steps/remote_service_steps.rb +0 -92
- data/features/supports_read_timeout_option.feature +0 -13
- data/features/supports_redirection.feature +0 -22
- data/features/supports_timeout_option.feature +0 -13
- data/spec/fixtures/delicious.xml +0 -23
- data/spec/fixtures/empty.xml +0 -0
- data/spec/fixtures/example.html +0 -10
- data/spec/fixtures/ssl/generate.sh +0 -29
- data/spec/fixtures/ssl/generated/bogushost.crt +0 -29
- data/spec/fixtures/ssl/generated/ca.crt +0 -31
- data/spec/fixtures/ssl/generated/ca.key +0 -52
- data/spec/fixtures/ssl/generated/selfsigned.crt +0 -29
- data/spec/fixtures/ssl/generated/server.crt +0 -30
- data/spec/fixtures/ssl/generated/server.key +0 -52
- data/spec/fixtures/ssl/openssl-exts.cnf +0 -9
- data/spec/fixtures/tiny.gif +0 -0
- data/spec/fixtures/twitter.csv +0 -2
- data/spec/fixtures/twitter.json +0 -1
- data/spec/fixtures/twitter.xml +0 -403
- data/spec/fixtures/undefined_method_add_node_for_nil.xml +0 -2
- data/spec/httparty/connection_adapter_spec.rb +0 -628
- data/spec/httparty/cookie_hash_spec.rb +0 -100
- data/spec/httparty/exception_spec.rb +0 -45
- data/spec/httparty/hash_conversions_spec.rb +0 -58
- data/spec/httparty/logger/apache_formatter_spec.rb +0 -40
- data/spec/httparty/logger/curl_formatter_spec.rb +0 -119
- data/spec/httparty/logger/logger_spec.rb +0 -43
- data/spec/httparty/logger/logstash_formatter_spec.rb +0 -44
- data/spec/httparty/net_digest_auth_spec.rb +0 -270
- data/spec/httparty/parser_spec.rb +0 -190
- data/spec/httparty/request/body_spec.rb +0 -165
- data/spec/httparty/request_spec.rb +0 -1389
- data/spec/httparty/response_fragment_spec.rb +0 -17
- data/spec/httparty/response_spec.rb +0 -374
- data/spec/httparty/ssl_spec.rb +0 -82
- data/spec/httparty_spec.rb +0 -943
- data/spec/spec_helper.rb +0 -57
- data/spec/support/ssl_test_helper.rb +0 -47
- data/spec/support/ssl_test_server.rb +0 -80
- data/spec/support/stub_response.rb +0 -50
@@ -1,100 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::CookieHash do
|
4
|
-
before(:each) do
|
5
|
-
@cookie_hash = HTTParty::CookieHash.new
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#add_cookies" do
|
9
|
-
describe "with a hash" do
|
10
|
-
it "should add new key/value pairs to the hash" do
|
11
|
-
@cookie_hash.add_cookies(foo: "bar")
|
12
|
-
@cookie_hash.add_cookies(rofl: "copter")
|
13
|
-
expect(@cookie_hash.length).to eql(2)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should overwrite any existing key" do
|
17
|
-
@cookie_hash.add_cookies(foo: "bar")
|
18
|
-
@cookie_hash.add_cookies(foo: "copter")
|
19
|
-
expect(@cookie_hash.length).to eql(1)
|
20
|
-
expect(@cookie_hash[:foo]).to eql("copter")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "with a string" do
|
25
|
-
it "should add new key/value pairs to the hash" do
|
26
|
-
@cookie_hash.add_cookies("first=one; second=two; third")
|
27
|
-
expect(@cookie_hash[:first]).to eq('one')
|
28
|
-
expect(@cookie_hash[:second]).to eq('two')
|
29
|
-
expect(@cookie_hash[:third]).to eq(nil)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should overwrite any existing key" do
|
33
|
-
@cookie_hash[:foo] = 'bar'
|
34
|
-
@cookie_hash.add_cookies("foo=tar")
|
35
|
-
expect(@cookie_hash.length).to eql(1)
|
36
|
-
expect(@cookie_hash[:foo]).to eql("tar")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should handle '=' within cookie value" do
|
40
|
-
@cookie_hash.add_cookies("first=one=1; second=two=2==")
|
41
|
-
expect(@cookie_hash.keys).to include(:first, :second)
|
42
|
-
expect(@cookie_hash[:first]).to eq('one=1')
|
43
|
-
expect(@cookie_hash[:second]).to eq('two=2==')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'with other class' do
|
48
|
-
it "should error" do
|
49
|
-
expect {
|
50
|
-
@cookie_hash.add_cookies([])
|
51
|
-
}.to raise_error(RuntimeError)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# The regexen are required because Hashes aren't ordered, so a test against
|
57
|
-
# a hardcoded string was randomly failing.
|
58
|
-
describe "#to_cookie_string" do
|
59
|
-
before(:each) do
|
60
|
-
@cookie_hash.add_cookies(foo: "bar")
|
61
|
-
@cookie_hash.add_cookies(rofl: "copter")
|
62
|
-
@s = @cookie_hash.to_cookie_string
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should format the key/value pairs, delimited by semi-colons" do
|
66
|
-
expect(@s).to match(/foo=bar/)
|
67
|
-
expect(@s).to match(/rofl=copter/)
|
68
|
-
expect(@s).to match(/^\w+=\w+; \w+=\w+$/)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should not include client side only cookies" do
|
72
|
-
@cookie_hash.add_cookies(path: "/")
|
73
|
-
@s = @cookie_hash.to_cookie_string
|
74
|
-
expect(@s).not_to match(/path=\//)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should not include client side only cookies even when attributes use camal case" do
|
78
|
-
@cookie_hash.add_cookies(Path: "/")
|
79
|
-
@s = @cookie_hash.to_cookie_string
|
80
|
-
expect(@s).not_to match(/Path=\//)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should not mutate the hash" do
|
84
|
-
original_hash = {
|
85
|
-
"session" => "91e25e8b-6e32-418d-c72f-2d18adf041cd",
|
86
|
-
"Max-Age" => "15552000",
|
87
|
-
"cart" => "91e25e8b-6e32-418d-c72f-2d18adf041cd",
|
88
|
-
"httponly" => nil,
|
89
|
-
"Path" => "/",
|
90
|
-
"secure" => nil,
|
91
|
-
}
|
92
|
-
|
93
|
-
cookie_hash = HTTParty::CookieHash[original_hash]
|
94
|
-
|
95
|
-
cookie_hash.to_cookie_string
|
96
|
-
|
97
|
-
expect(cookie_hash).to eq(original_hash)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Error do
|
4
|
-
subject { described_class }
|
5
|
-
|
6
|
-
describe '#ancestors' do
|
7
|
-
subject { super().ancestors }
|
8
|
-
it { is_expected.to include(StandardError) }
|
9
|
-
end
|
10
|
-
|
11
|
-
describe HTTParty::UnsupportedFormat do
|
12
|
-
describe '#ancestors' do
|
13
|
-
subject { super().ancestors }
|
14
|
-
it { is_expected.to include(HTTParty::Error) }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe HTTParty::UnsupportedURIScheme do
|
19
|
-
describe '#ancestors' do
|
20
|
-
subject { super().ancestors }
|
21
|
-
it { is_expected.to include(HTTParty::Error) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe HTTParty::ResponseError do
|
26
|
-
describe '#ancestors' do
|
27
|
-
subject { super().ancestors }
|
28
|
-
it { is_expected.to include(HTTParty::Error) }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe HTTParty::RedirectionTooDeep do
|
33
|
-
describe '#ancestors' do
|
34
|
-
subject { super().ancestors }
|
35
|
-
it { is_expected.to include(HTTParty::ResponseError) }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe HTTParty::DuplicateLocationHeader do
|
40
|
-
describe '#ancestors' do
|
41
|
-
subject { super().ancestors }
|
42
|
-
it { is_expected.to include(HTTParty::ResponseError) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::HashConversions do
|
4
|
-
describe ".to_params" do
|
5
|
-
it "creates a params string from a hash" do
|
6
|
-
hash = {
|
7
|
-
name: "bob",
|
8
|
-
address: {
|
9
|
-
street: '111 ruby ave.',
|
10
|
-
city: 'ruby central',
|
11
|
-
phones: ['111-111-1111', '222-222-2222']
|
12
|
-
}
|
13
|
-
}
|
14
|
-
expect(HTTParty::HashConversions.to_params(hash)).to eq("name=bob&address[street]=111%20ruby%20ave.&address[city]=ruby%20central&address[phones][]=111-111-1111&address[phones][]=222-222-2222")
|
15
|
-
end
|
16
|
-
|
17
|
-
context "nested params" do
|
18
|
-
it 'creates a params string from a hash' do
|
19
|
-
hash = { marketing_event: { marketed_resources: [ {type:"product", id: 57474842640 } ] } }
|
20
|
-
expect(HTTParty::HashConversions.to_params(hash)).to eq("marketing_event[marketed_resources][][type]=product&marketing_event[marketed_resources][][id]=57474842640")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe ".normalize_param" do
|
26
|
-
context "value is an array" do
|
27
|
-
it "creates a params string" do
|
28
|
-
expect(
|
29
|
-
HTTParty::HashConversions.normalize_param(:people, ["Bob Jones", "Mike Smith"])
|
30
|
-
).to eq("people[]=Bob%20Jones&people[]=Mike%20Smith&")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "value is an empty array" do
|
35
|
-
it "creates a params string" do
|
36
|
-
expect(
|
37
|
-
HTTParty::HashConversions.normalize_param(:people, [])
|
38
|
-
).to eq("people[]=&")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "value is hash" do
|
43
|
-
it "creates a params string" do
|
44
|
-
expect(
|
45
|
-
HTTParty::HashConversions.normalize_param(:person, { name: "Bob Jones" })
|
46
|
-
).to eq("person[name]=Bob%20Jones&")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "value is a string" do
|
51
|
-
it "creates a params string" do
|
52
|
-
expect(
|
53
|
-
HTTParty::HashConversions.normalize_param(:name, "Bob Jones")
|
54
|
-
).to eq("name=Bob%20Jones&")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Logger::ApacheFormatter do
|
4
|
-
let(:subject) { described_class.new(logger_double, :info) }
|
5
|
-
let(:logger_double) { double('Logger') }
|
6
|
-
let(:request_double) { double('Request', http_method: Net::HTTP::Get, path: "http://my.domain.com/my_path") }
|
7
|
-
let(:request_time) { Time.new.strftime("%Y-%m-%d %H:%M:%S %z") }
|
8
|
-
|
9
|
-
before do
|
10
|
-
expect(logger_double).to receive(:info).with(log_message)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#format" do
|
14
|
-
let(:log_message) { "[HTTParty] [#{request_time}] 302 \"GET http://my.domain.com/my_path\" - " }
|
15
|
-
|
16
|
-
it "formats a response in a style that resembles apache's access log" do
|
17
|
-
response_double = double(
|
18
|
-
code: 302,
|
19
|
-
:[] => nil
|
20
|
-
)
|
21
|
-
|
22
|
-
subject.format(request_double, response_double)
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'when there is a parsed response' do
|
26
|
-
let(:log_message) { "[HTTParty] [#{request_time}] 200 \"GET http://my.domain.com/my_path\" 512 "}
|
27
|
-
|
28
|
-
it "can handle the Content-Length header" do
|
29
|
-
# Simulate a parsed response that is an array, where accessing a string key will raise an error. See Issue #299.
|
30
|
-
response_double = double(
|
31
|
-
code: 200,
|
32
|
-
headers: { 'Content-Length' => 512 }
|
33
|
-
)
|
34
|
-
allow(response_double).to receive(:[]).with('Content-Length').and_raise(TypeError.new('no implicit conversion of String into Integer'))
|
35
|
-
|
36
|
-
subject.format(request_double, response_double)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Logger::CurlFormatter do
|
4
|
-
describe "#format" do
|
5
|
-
let(:logger) { double('Logger') }
|
6
|
-
let(:response_object) { Net::HTTPOK.new('1.1', 200, 'OK') }
|
7
|
-
let(:parsed_response) { lambda { {"foo" => "bar"} } }
|
8
|
-
|
9
|
-
let(:response) do
|
10
|
-
HTTParty::Response.new(request, response_object, parsed_response)
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:request) do
|
14
|
-
HTTParty::Request.new(Net::HTTP::Get, 'http://foo.bar.com/')
|
15
|
-
end
|
16
|
-
|
17
|
-
subject { described_class.new(logger, :info) }
|
18
|
-
|
19
|
-
before do
|
20
|
-
allow(logger).to receive(:info)
|
21
|
-
allow(request).to receive(:raw_body).and_return('content')
|
22
|
-
allow(response_object).to receive_messages(body: "{foo:'bar'}")
|
23
|
-
response_object['header-key'] = 'header-value'
|
24
|
-
|
25
|
-
subject.format request, response
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'when request is logged' do
|
29
|
-
context "and request's option 'base_uri' is not present" do
|
30
|
-
it 'logs url' do
|
31
|
-
expect(logger).to have_received(:info).with(/\[HTTParty\] \[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\ [+-]\d{4}\] > GET http:\/\/foo.bar.com/)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "and request's option 'base_uri' is present" do
|
36
|
-
let(:request) do
|
37
|
-
HTTParty::Request.new(Net::HTTP::Get, '/path', base_uri: 'http://foo.bar.com')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'logs url' do
|
41
|
-
expect(logger).to have_received(:info).with(/\[HTTParty\] \[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\ [+-]\d{4}\] > GET http:\/\/foo.bar.com\/path/)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'and headers are not present' do
|
46
|
-
it 'not log Headers' do
|
47
|
-
expect(logger).not_to have_received(:info).with(/Headers/)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'and headers are present' do
|
52
|
-
let(:request) do
|
53
|
-
HTTParty::Request.new(Net::HTTP::Get, '/path', base_uri: 'http://foo.bar.com', headers: { key: 'value' })
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'logs Headers' do
|
57
|
-
expect(logger).to have_received(:info).with(/Headers/)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'logs headers keys' do
|
61
|
-
expect(logger).to have_received(:info).with(/key: value/)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'and query is not present' do
|
66
|
-
it 'not logs Query' do
|
67
|
-
expect(logger).not_to have_received(:info).with(/Query/)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'and query is present' do
|
72
|
-
let(:request) do
|
73
|
-
HTTParty::Request.new(Net::HTTP::Get, '/path', query: { key: 'value' })
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'logs Query' do
|
77
|
-
expect(logger).to have_received(:info).with(/Query/)
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'logs query params' do
|
81
|
-
expect(logger).to have_received(:info).with(/key: value/)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when request raw_body is present' do
|
86
|
-
it 'not logs request body' do
|
87
|
-
expect(logger).to have_received(:info).with(/content/)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'when response is logged' do
|
93
|
-
it 'logs http version and response code' do
|
94
|
-
expect(logger).to have_received(:info).with(/HTTP\/1.1 200/)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'logs headers' do
|
98
|
-
expect(logger).to have_received(:info).with(/Header-key: header-value/)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'logs body' do
|
102
|
-
expect(logger).to have_received(:info).with(/{foo:'bar'}/)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
it "formats a response in a style that resembles a -v curl" do
|
107
|
-
logger_double = double
|
108
|
-
expect(logger_double).to receive(:info).with(
|
109
|
-
/\[HTTParty\] \[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\ [+-]\d{4}\] > GET http:\/\/localhost/)
|
110
|
-
|
111
|
-
subject = described_class.new(logger_double, :info)
|
112
|
-
|
113
|
-
stub_http_response_with("example.html")
|
114
|
-
|
115
|
-
response = HTTParty::Request.new.perform
|
116
|
-
subject.format(response.request, response)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Logger do
|
4
|
-
describe ".build" do
|
5
|
-
subject { HTTParty::Logger }
|
6
|
-
|
7
|
-
it "defaults level to :info" do
|
8
|
-
logger_double = double
|
9
|
-
expect(subject.build(logger_double, nil, nil).level).to eq(:info)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "defaults format to :apache" do
|
13
|
-
logger_double = double
|
14
|
-
expect(subject.build(logger_double, nil, nil)).to be_an_instance_of(HTTParty::Logger::ApacheFormatter)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "builds :curl style logger" do
|
18
|
-
logger_double = double
|
19
|
-
expect(subject.build(logger_double, nil, :curl)).to be_an_instance_of(HTTParty::Logger::CurlFormatter)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "builds :logstash style logger" do
|
23
|
-
logger_double = double
|
24
|
-
expect(subject.build(logger_double, nil, :logstash)).to be_an_instance_of(HTTParty::Logger::LogstashFormatter)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "builds :custom style logger" do
|
28
|
-
CustomFormatter = Class.new(HTTParty::Logger::CurlFormatter)
|
29
|
-
HTTParty::Logger.add_formatter(:custom, CustomFormatter)
|
30
|
-
|
31
|
-
logger_double = double
|
32
|
-
expect(subject.build(logger_double, nil, :custom)).
|
33
|
-
to be_an_instance_of(CustomFormatter)
|
34
|
-
end
|
35
|
-
it "raises error when formatter exists" do
|
36
|
-
CustomFormatter2= Class.new(HTTParty::Logger::CurlFormatter)
|
37
|
-
HTTParty::Logger.add_formatter(:custom2, CustomFormatter2)
|
38
|
-
|
39
|
-
expect{ HTTParty::Logger.add_formatter(:custom2, CustomFormatter2) }.
|
40
|
-
to raise_error HTTParty::Error
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe HTTParty::Logger::LogstashFormatter do
|
4
|
-
let(:severity) { :info }
|
5
|
-
let(:http_method) { 'GET' }
|
6
|
-
let(:path) { 'http://my.domain.com/my_path' }
|
7
|
-
let(:logger_double) { double('Logger') }
|
8
|
-
let(:request_double) { double('Request', http_method: Net::HTTP::Get, path: "#{path}") }
|
9
|
-
let(:request_time) { Time.new.strftime("%Y-%m-%d %H:%M:%S %z") }
|
10
|
-
let(:log_message) do
|
11
|
-
{
|
12
|
-
'@timestamp' => request_time,
|
13
|
-
'@version' => 1,
|
14
|
-
'content_length' => content_length || '-',
|
15
|
-
'http_method' => http_method,
|
16
|
-
'message' => message,
|
17
|
-
'path' => path,
|
18
|
-
'response_code' => response_code,
|
19
|
-
'severity' => severity,
|
20
|
-
'tags' => ['HTTParty'],
|
21
|
-
}.to_json
|
22
|
-
end
|
23
|
-
|
24
|
-
subject { described_class.new(logger_double, severity) }
|
25
|
-
|
26
|
-
before do
|
27
|
-
expect(logger_double).to receive(:info).with(log_message)
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#format" do
|
31
|
-
let(:response_code) { 302 }
|
32
|
-
let(:content_length) { '-' }
|
33
|
-
let(:message) { "[HTTParty] #{response_code} \"#{http_method} #{path}\" #{content_length} " }
|
34
|
-
|
35
|
-
it "formats a response to be compatible with Logstash" do
|
36
|
-
response_double = double(
|
37
|
-
code: response_code,
|
38
|
-
:[] => nil
|
39
|
-
)
|
40
|
-
|
41
|
-
subject.format(request_double, response_double)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|