http_event_logger 0.1.0.rc1 → 0.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1c6e13a02bf58df078b6db91d89d34e04a3ab46
4
- data.tar.gz: 8743f10e8bc7672991d0447cf8dad126d84d7e7f
3
+ metadata.gz: 5bd3bebcc3b5665faa4689a9baa85c01c1021527
4
+ data.tar.gz: c405a28f0576ebbb46fa24f41c2e23c0dbbe1d3f
5
5
  SHA512:
6
- metadata.gz: 5827ef887a7b2a13a9d9d29a684eb1b75963047ed30c7a4c9717c5346a2268ad94521dd363f8c57b84311306242e52d4e732f091f0aa9882ea0fccfeea9f169c
7
- data.tar.gz: 27e747db5d476fbc7fc9db0adf5a759ca1ea5d750c4b70ddf8219a60956b7bf8bea9cdda18aeabbd0c0cc3bc9f1f95f3d0fd8ebc56021954dfcf966512809079
6
+ metadata.gz: ce05d87946e07222ac313134ece1ec2b9891f829222710087c9e682ff0ddec1a90b36d2040caf5c794c9cd67b8715422081b7bfbb2510ae27249141b30fdc3b3
7
+ data.tar.gz: afc39c1939139a2565ffc45003823f8e45f1f1da9231f525a94a51be81f78cf78a3e7f79640a6883297b75d0e0f99602638e69291d21afe9f72db7e26748da3c
@@ -8,13 +8,20 @@ module HttpEventLogger
8
8
  end
9
9
 
10
10
  def [](name)
11
- @headers.is_a?(Hash) ? @headers[name] : nil
11
+ @headers.is_a?(Hash) ? header_value_for(name) : nil
12
12
  end
13
13
 
14
14
  def to_s
15
15
  @headers.is_a?(String) ? @headers : @headers.map { |key, value| "#{key}: #{value}" }.join(", ")
16
16
  end
17
17
 
18
+ private
19
+
20
+ def header_value_for(name)
21
+ header = @headers.find { |key, value| key.downcase == name.downcase }
22
+ header ? header[1] : nil
23
+ end
24
+
18
25
  end
19
26
 
20
27
  end
@@ -1,3 +1,3 @@
1
1
  module HttpEventLogger
2
- VERSION = "0.1.0.rc1".freeze
2
+ VERSION = "0.1.0.rc2".freeze
3
3
  end
@@ -0,0 +1,69 @@
1
+ describe HttpEventLogger::Event::Headers do
2
+
3
+ let(:headers) { HttpEventLogger::Event::Headers.new(provided_headers) }
4
+
5
+ context "when a hash is provided" do
6
+
7
+ let(:provided_headers) { { "some_key" => "some value", "some_other_key" => "some other value" } }
8
+
9
+ describe "#[]" do
10
+
11
+ context "and the name provided exactly matches a header name" do
12
+
13
+ it "returns the value of the header" do
14
+ expect(headers["some_key"]).to eql("some value")
15
+ end
16
+
17
+ end
18
+
19
+ context "and the name provided is a case insensitive match for a header name" do
20
+
21
+ it "returns the value of the header" do
22
+ expect(headers["Some_Key"]).to eql("some value")
23
+ end
24
+
25
+ end
26
+
27
+ context "and the the name provided does not match a header name" do
28
+
29
+ it "returns nil" do
30
+ expect(headers["does_not_match"]).to eql(nil)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ describe "#to_s" do
38
+
39
+ it "returns a string containing all header keys and values" do
40
+ expect(headers.to_s).to eql("some_key: some value, some_other_key: some other value")
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
47
+ context "when a string is provided" do
48
+
49
+ let(:provided_headers) { "some_key some value" }
50
+
51
+ describe "#[]" do
52
+
53
+ it "returns nil" do
54
+ expect(headers["some_key"]).to eql(nil)
55
+ end
56
+
57
+ end
58
+
59
+ describe "#to_s" do
60
+
61
+ it "returns the string" do
62
+ expect(headers.to_s).to eql(provided_headers)
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_event_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
4
+ version: 0.1.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman
@@ -243,6 +243,7 @@ files:
243
243
  - "./lib/http_event_logger/logger.rb"
244
244
  - "./lib/http_event_logger/version.rb"
245
245
  - "./spec/http_event_logger_integration_spec.rb"
246
+ - "./spec/lib/http_event_logger/event/headers_spec.rb"
246
247
  - "./spec/spec_helper.rb"
247
248
  - "./spec/support/custom_logger.rb"
248
249
  - "./spec/support/driver/base.rb"
@@ -283,6 +284,7 @@ specification_version: 4
283
284
  summary: Logs HTTP requests issued via numerous libraries
284
285
  test_files:
285
286
  - "./spec/http_event_logger_integration_spec.rb"
287
+ - "./spec/lib/http_event_logger/event/headers_spec.rb"
286
288
  - "./spec/spec_helper.rb"
287
289
  - "./spec/support/custom_logger.rb"
288
290
  - "./spec/support/driver/base.rb"