http_stub 0.14.0.rc4 → 0.14.0.rc5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6135f0cdbd62b324fd90c2c2262df63b191ada36
4
- data.tar.gz: 43316b361b5b86172713fd5b89250576f5a7c20e
3
+ metadata.gz: c0c96ca88114548b718056ae0fc9fabd49ccfdd5
4
+ data.tar.gz: 5ab01f22d067613d869ba5709ed4ac69cab80bdc
5
5
  SHA512:
6
- metadata.gz: 2ab8fb26a5673af9a178a01279538a62419b5ce6f47165089ded6cb45cf79ac325af950256c94f6e30e9dfbf05f45b07c3fb1e606a3da98917732638a33a4254
7
- data.tar.gz: f80869657a7da4fe4f613b322491d8c3d72297432d4150ef049cff8e289f0b6d370a9923b34e835846059fac31d7011d2c0bb32e81748c435b40f13a9831c0b7
6
+ metadata.gz: 1f8095e3f1cf0701e2b9e5158a8874f4532ffd82411c7758d042e5b4f0735365d577ce3601e76bf6119f5aaaada226466597f56a2334a0231eaf7344e773d095
7
+ data.tar.gz: 1ebbbf072c32a28a2beeb8ab79c6767066f14bd3b83409eac5fa26bc5f8722655fb26019a5e2c4404b8fab670aa4eb5fd1d4c7b8a26b8c145f2fb32a0d127198
@@ -5,7 +5,7 @@ module HttpStub
5
5
 
6
6
  def self.parse(request)
7
7
  request.env.reduce({}) do |result, element|
8
- match = element[0].match(/^HTTP_(.*)/)
8
+ match = element[0].match(/^(?:HTTP_)?([A-Z0-9_]+)$/)
9
9
  result[match[1]] = element[1] if match
10
10
  result
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module HttpStub
2
- VERSION = "0.14.0.rc4".freeze
2
+ VERSION = "0.14.0.rc5".freeze
3
3
  end
@@ -1,35 +1,45 @@
1
1
  describe HttpStub::Models::RequestHeaderParser do
2
2
 
3
- let(:non_http_env_elements) do
3
+ let(:non_header_env_elements) do
4
4
  {
5
- "GATEWAY_INTERFACE" => "CGI/1.1",
6
- "QUERY_STRING" => "some string",
7
- "REMOTE_ADDR" => "127.0.0.1",
8
- "SCRIPT_NAME" => "some script",
9
- "SERVER_NAME" => "localhost",
5
+ "rack.version" => [1, 3],
6
+ "rack.multithreaded" => true,
7
+ "rack.multiprocess" => false
10
8
  }
11
9
  end
12
- let(:env) { non_http_env_elements.merge(http_env_elements) }
10
+ let(:env) { non_header_env_elements.merge(header_env_elements) }
13
11
  let(:request) { double("HttpRequest", env: env) }
14
12
 
15
- describe ".parse" do
16
-
17
- describe "when the request contains request environment entries prefixed with 'HTTP_'" do
13
+ describe "::parse" do
18
14
 
19
- let(:http_env_elements) { { "HTTP_KEY1" => "value1", "HTTP_KEY2" => "value2", "HTTP_KEY3" => "value3" } }
15
+ describe "when the request contains environment entries in upper case" do
20
16
 
21
- it "returns a hash containing only those entries with the prefix removed" do
22
- expect(HttpStub::Models::RequestHeaderParser.parse(request)).to eql({ "KEY1" => "value1",
23
- "KEY2" => "value2",
24
- "KEY3" => "value3" })
17
+ let(:header_env_elements) { { "KEY_1" => "value1", "KEY_2" => "value2", "KEY_3" => "value3" } }
18
+
19
+ it "returns a hash containing those entries" do
20
+ expect(HttpStub::Models::RequestHeaderParser.parse(request)).to eql("KEY_1" => "value1",
21
+ "KEY_2" => "value2",
22
+ "KEY_3" => "value3")
25
23
  end
26
24
 
27
25
  end
28
-
29
- describe "when the request does not contain request environment entries prefixed with 'HTTP_'" do
30
26
 
31
- let(:http_env_elements) { {} }
32
-
27
+ describe "when the request contains environment entries in upper case prefixed with 'HTTP_'" do
28
+
29
+ let(:header_env_elements) { { "HTTP_KEY_1" => "value1", "HTTP_KEY_2" => "value2", "HTTP_KEY_3" => "value3" } }
30
+
31
+ it "returns a hash containing those entries with the prefix removed" do
32
+ expect(HttpStub::Models::RequestHeaderParser.parse(request)).to include("KEY_1" => "value1",
33
+ "KEY_2" => "value2",
34
+ "KEY_3" => "value3")
35
+ end
36
+
37
+ end
38
+
39
+ describe "when only has environment entries in lower case" do
40
+
41
+ let(:header_env_elements) { {} }
42
+
33
43
  it "returns an empty hash" do
34
44
  expect(HttpStub::Models::RequestHeaderParser.parse(request)).to eql({})
35
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_stub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0.rc4
4
+ version: 0.14.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ueckerman