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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/pact/consumer/mock_service/rack_request_helper.rb +13 -2
- data/lib/pact/mock_service/control_server/run.rb +1 -0
- data/lib/pact/mock_service/run.rb +1 -0
- data/lib/pact/mock_service/server/webrick_request_monkeypatch.rb +15 -0
- data/lib/pact/mock_service/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f39b2196b6e3bb4b78b25d97581128eadf84f7a00d31ba6cac6a7bd2f3e4e48
|
4
|
+
data.tar.gz: 7f6ebd1c45f8ec2fdc3b4e241eecbc673db7efbe5cd926882c1d739a488388bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c4dc93f7b56c19b53ce4b6387f4da8d2353f3253b212fa172e7f026b00d60fbe210bdb20c59486d729772c150408a9173a568245c2d9c4ce55ccc9e2d6e61f
|
7
|
+
data.tar.gz: f106889170d931af0102e2bd393a51b33fa1bcb9e3dbb4a7a7c8ac9d186ef798af5914a7250b1ac8db2156911909f3f96ff63ef33b8144087d3934f9d7107cbb
|
data/CHANGELOG.md
CHANGED
@@ -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(
|
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
|
@@ -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
|
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.
|
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-
|
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
|