pact-mock_service 2.7.0 → 2.7.1

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
  SHA256:
3
- metadata.gz: 5a983f436b468fd2f527a129750823d49276141e1246817da7124225a12d2b6e
4
- data.tar.gz: ebf7bee8331a4f26e127adcbe8d79f36b6fad80c0f22963753d265990f735369
3
+ metadata.gz: 8f39b2196b6e3bb4b78b25d97581128eadf84f7a00d31ba6cac6a7bd2f3e4e48
4
+ data.tar.gz: 7f6ebd1c45f8ec2fdc3b4e241eecbc673db7efbe5cd926882c1d739a488388bf
5
5
  SHA512:
6
- metadata.gz: de5168f4ba6c88f9e7ea3dd7f03b64e105a37f94a33975d4f20c03b58af328ae18f57ee96c6919bf520325bb850c37be48effa99b877de2e6e95ad17ffd666b2
7
- data.tar.gz: 5b0fd099ed6d5ac6f905e8e0ba148b1ea37757e02657ea3db56889bd5f03077ab1844c9348ade2af94b0ef3e42cfb58185a402cb7d1c5677056fd93e5567f461
6
+ metadata.gz: 99c4dc93f7b56c19b53ce4b6387f4da8d2353f3253b212fa172e7f026b00d60fbe210bdb20c59486d729772c150408a9173a568245c2d9c4ce55ccc9e2d6e61f
7
+ data.tar.gz: f106889170d931af0102e2bd393a51b33fa1bcb9e3dbb4a7a7c8ac9d186ef798af5914a7250b1ac8db2156911909f3f96ff63ef33b8144087d3934f9d7107cbb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ <a name="v2.7.1"></a>
2
+ ### v2.7.1 (2018-05-09)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * ensure underscored headers are maintained ([0724701](/../../commit/0724701))
8
+
9
+
1
10
  <a name="v2.7.0"></a>
2
11
  ### v2.7.0 (2018-05-04)
3
12
 
@@ -38,14 +38,25 @@ module Pact
38
38
 
39
39
  def headers_from env
40
40
  headers = env.reject{ |key, value| !(key.start_with?("HTTP") || key == 'CONTENT_TYPE' || key == 'CONTENT_LENGTH')}
41
- headers.inject({}) do | hash, header |
41
+ dasherized_headers = headers.inject({}) do | hash, header |
42
42
  hash[standardise_header(header.first)] = header.last
43
43
  hash
44
44
  end
45
+ # This header is set in lib/pact/mock_service/server/webrick_request_monkeypatch.rb to allow use to
46
+ # restore the original header names with underscores.
47
+ restore_underscored_header_names(dasherized_headers, (env['X_PACT_UNDERSCORED_HEADER_NAMES'] || '').split(","))
45
48
  end
46
49
 
47
50
  def standardise_header header
48
- header.gsub(/^HTTP_/, '').split("_").collect{|word| word[0] + word[1..-1].downcase}.join("-")
51
+ header.gsub(/^HTTP_/, '').split(/[_-]/).collect{|word| word[0].upcase + word[1..-1].downcase}.join("-")
52
+ end
53
+
54
+ def restore_underscored_header_names dasherized_headers, original_header_names
55
+ original_header_names.each_with_object(dasherized_headers) do | original_header_name, headers |
56
+ if headers.key?(standardise_header(original_header_name))
57
+ headers[original_header_name] = headers.delete(standardise_header(original_header_name))
58
+ end
59
+ end
49
60
  end
50
61
  end
51
62
  end
@@ -1,4 +1,5 @@
1
1
  require 'pact/mock_service/control_server/app'
2
+ require 'pact/mock_service/server/webrick_request_monkeypatch'
2
3
 
3
4
  module Pact
4
5
  module MockService
@@ -2,6 +2,7 @@ require 'find_a_port'
2
2
  require 'pact/mock_service/app'
3
3
  require 'pact/consumer/mock_service/set_location'
4
4
  require 'pact/mock_service/run'
5
+ require 'pact/mock_service/server/webrick_request_monkeypatch'
5
6
 
6
7
  module Pact
7
8
  module MockService
@@ -0,0 +1,15 @@
1
+ module WEBrick
2
+ class HTTPRequest
3
+ alias_method :pact_original_meta_vars, :meta_vars
4
+
5
+ def meta_vars
6
+ original_underscored_headers = []
7
+ self.each{|key, val| original_underscored_headers << key if key.include?("_") }
8
+ # This header allows us to restore the original format (eg. underscored) of the headers
9
+ # when parsing the incoming Rack env back to a response object.
10
+ vars = pact_original_meta_vars
11
+ vars["X_PACT_UNDERSCORED_HEADER_NAMES"] = original_underscored_headers.join(",")
12
+ vars
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "2.7.0"
3
+ VERSION = "2.7.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-05-04 00:00:00.000000000 Z
15
+ date: 2018-05-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack
@@ -374,6 +374,7 @@ files:
374
374
  - lib/pact/mock_service/server/respawn.rb
375
375
  - lib/pact/mock_service/server/spawn.rb
376
376
  - lib/pact/mock_service/server/wait_for_server_up.rb
377
+ - lib/pact/mock_service/server/webrick_request_monkeypatch.rb
377
378
  - lib/pact/mock_service/session.rb
378
379
  - lib/pact/mock_service/spawn.rb
379
380
  - lib/pact/mock_service/version.rb