pact-support 1.2.5 → 1.2.99.alpha.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 +2 -5
- data/RELEASING.md +12 -2
- data/lib/pact/consumer_contract/consumer_contract.rb +15 -9
- data/lib/pact/consumer_contract/file_name.rb +1 -5
- data/lib/pact/consumer_contract/http_consumer_contract_parser.rb +26 -0
- data/lib/pact/consumer_contract/interaction.rb +5 -1
- data/lib/pact/shared/json_differ.rb +1 -1
- data/lib/pact/support/version.rb +1 -1
- data/pact-support.gemspec +0 -2
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +35 -32
- data/spec/lib/pact/consumer_contract/file_name_spec.rb +2 -11
- data/tasks/spec.rake +0 -1
- metadata +5 -34
- data/script/release.sh +0 -9
- data/tasks/release.rake +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb6aa8891e3b73c96d764ca9dd4c43849dc2972b
|
4
|
+
data.tar.gz: 79d896556e2d8eb9679aa41ae84200fe26fec695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c3ca1df6aef0c0c5fa2944f9a75980dd5c2970d99c23c3940d8a1812fce409f9ac2f527733a3c9d06505453ae09b7dbddc6383170b62b1191c4036c0ffb6dac
|
7
|
+
data.tar.gz: b16006ef3b27268ecfa08793847709f9aee236c4b7ebf11a8a539bf41ffc4f38e7a1e76d63149e04bf9fc7bc916b05660e799e3bf974f487c35ab52a9e951104
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
|
2
|
-
### v1.2.5 (2018-02-16)
|
1
|
+
Do this to generate your change history
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
* replace backslashes in pact dir path with forward slashes ([a1b5013](/../../commit/a1b5013))
|
3
|
+
git log --pretty=format:' * %h - %s (%an, %ad)'
|
7
4
|
|
8
5
|
### 1.2.4 (2017-10-30)
|
9
6
|
* 80bbdcc - fix: remove unused dependency on rack-test (Beth Skurrie, Mon Oct 30 09:52:22 2017 +1100)
|
data/RELEASING.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Releasing
|
2
2
|
|
3
|
-
|
3
|
+
1. Increment the version in `lib/pact/support/version.rb`
|
4
|
+
2. Update the `CHANGELOG.md` using:
|
4
5
|
|
5
|
-
|
6
|
+
$ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
|
7
|
+
|
8
|
+
3. Add files to git
|
9
|
+
|
10
|
+
$ git add CHANGELOG.md lib/pact/support/version.rb
|
11
|
+
$ git commit -m "chore(release): version $(ruby -r ./lib/pact/support/version.rb -e "puts Pact::Support::VERSION")"
|
12
|
+
|
13
|
+
3. Release:
|
14
|
+
|
15
|
+
$ bundle exec rake release
|
@@ -10,9 +10,9 @@ require 'pact/consumer_contract/service_consumer'
|
|
10
10
|
require 'pact/consumer_contract/service_provider'
|
11
11
|
require 'pact/consumer_contract/interaction'
|
12
12
|
require 'pact/consumer_contract/pact_file'
|
13
|
+
require 'pact/consumer_contract/http_consumer_contract_parser'
|
13
14
|
|
14
15
|
module Pact
|
15
|
-
|
16
16
|
class ConsumerContract
|
17
17
|
|
18
18
|
include SymbolizeKeys
|
@@ -29,13 +29,19 @@ module Pact
|
|
29
29
|
@provider = attributes[:provider]
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.add_parser consumer_contract_parser
|
33
|
+
parsers << consumer_contract_parser
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.parsers
|
37
|
+
@parsers ||= [Pact::HttpConsumerContractParser.new]
|
38
|
+
end
|
39
|
+
|
32
40
|
def self.from_hash(hash)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:interactions => hash[:interactions].collect { |hash| Interaction.from_hash(hash)}
|
38
|
-
)
|
41
|
+
parsers.each do | parser |
|
42
|
+
return parser.call(hash) if parser.can_parse?(hash)
|
43
|
+
end
|
44
|
+
raise Pact::Error.new("No consumer contract parser found for hash: #{hash}")
|
39
45
|
end
|
40
46
|
|
41
47
|
def self.from_json string
|
@@ -54,9 +60,9 @@ module Pact
|
|
54
60
|
def find_interaction criteria
|
55
61
|
interactions = find_interactions criteria
|
56
62
|
if interactions.size == 0
|
57
|
-
raise "Could not find interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}."
|
63
|
+
raise Pact::Error.new("Could not find interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}.")
|
58
64
|
elsif interactions.size > 1
|
59
|
-
raise "Found more than 1 interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}."
|
65
|
+
raise Pact::Error.new("Found more than 1 interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}.")
|
60
66
|
end
|
61
67
|
interactions.first
|
62
68
|
end
|
@@ -8,15 +8,11 @@ module Pact
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def file_path consumer_name, provider_name, pact_dir = Pact.configuration.pact_dir, options = {}
|
11
|
-
File.join(
|
11
|
+
File.join(pact_dir, file_name(consumer_name, provider_name, options))
|
12
12
|
end
|
13
13
|
|
14
14
|
def filenamify name
|
15
15
|
name.downcase.gsub(/\s/, '_')
|
16
16
|
end
|
17
|
-
|
18
|
-
def windows_safe(pact_dir)
|
19
|
-
pact_dir.gsub("\\", "/")
|
20
|
-
end
|
21
17
|
end
|
22
18
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Pact
|
2
|
+
class HttpConsumerContractParser
|
3
|
+
include SymbolizeKeys
|
4
|
+
|
5
|
+
def call(hash)
|
6
|
+
hash = symbolize_keys(hash)
|
7
|
+
interactions = if hash[:interactions]
|
8
|
+
hash[:interactions].collect { |hash| Interaction.from_hash(hash)}
|
9
|
+
elsif hash[:messages]
|
10
|
+
hash[:messages].collect { |hash| Message.from_hash(hash)}
|
11
|
+
else
|
12
|
+
[] # or raise an error?
|
13
|
+
end
|
14
|
+
|
15
|
+
ConsumerContract.new(
|
16
|
+
:consumer => ServiceConsumer.from_hash(hash[:consumer]),
|
17
|
+
:provider => ServiceProvider.from_hash(hash[:provider]),
|
18
|
+
:interactions => interactions
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def can_parse?(hash)
|
23
|
+
hash.key?('interactions') || hash.key?(:interactions)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -6,7 +6,7 @@ require 'pact/matching_rules'
|
|
6
6
|
require 'pact/errors'
|
7
7
|
|
8
8
|
module Pact
|
9
|
-
|
9
|
+
class Interaction
|
10
10
|
include ActiveSupportSupport
|
11
11
|
include SymbolizeKeys
|
12
12
|
|
@@ -36,6 +36,10 @@ module Pact
|
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
+
def http?
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
39
43
|
def validate!
|
40
44
|
raise Pact::InvalidInteractionError.new(self) unless description && request && response
|
41
45
|
end
|
@@ -5,7 +5,7 @@ module Pact
|
|
5
5
|
|
6
6
|
extend Matchers
|
7
7
|
|
8
|
-
# Delegates to https://github.com/
|
8
|
+
# Delegates to https://github.com/bethesque/pact-support/blob/master/lib/pact/matchers/matchers.rb#L25
|
9
9
|
def self.call expected, actual, options = {}
|
10
10
|
diff expected, actual, options
|
11
11
|
end
|
data/lib/pact/support/version.rb
CHANGED
data/pact-support.gemspec
CHANGED
@@ -34,6 +34,4 @@ Gem::Specification.new do |gem|
|
|
34
34
|
gem.add_development_dependency 'hashie', '~> 2.0'
|
35
35
|
gem.add_development_dependency 'activesupport'
|
36
36
|
gem.add_development_dependency 'appraisal'
|
37
|
-
gem.add_development_dependency 'conventional-changelog', '~>1.3'
|
38
|
-
gem.add_development_dependency 'bump', '~> 0.5'
|
39
37
|
end
|
@@ -3,50 +3,53 @@ require 'pact/consumer_contract'
|
|
3
3
|
|
4
4
|
module Pact
|
5
5
|
describe ConsumerContract do
|
6
|
-
|
7
6
|
describe ".from_json" do
|
7
|
+
|
8
8
|
let(:loaded_pact) { ConsumerContract.from_json(string) }
|
9
|
-
context "when the top level object is a ConsumerContract" do
|
10
|
-
let(:string) { '{"interactions":[{"request": {"path":"/path", "method" : "get"}, "response": {"status" : 200}}], "consumer": {"name" : "Bob"} , "provider": {"name" : "Mary"} }' }
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
context "with an HTTP contract" do
|
11
|
+
context "when the top level object is a ConsumerContract" do
|
12
|
+
let(:string) { '{"interactions":[{"request": {"path":"/path", "method" : "get"}, "response": {"status" : 200}}], "consumer": {"name" : "Bob"} , "provider": {"name" : "Mary"} }' }
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
it "should create a Pact" do
|
15
|
+
expect(loaded_pact).to be_instance_of ConsumerContract
|
16
|
+
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
it "should have interactions" do
|
19
|
+
expect(loaded_pact.interactions).to be_instance_of Array
|
20
|
+
end
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
it "should have a consumer" do
|
23
|
+
expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
|
24
|
+
end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
expect(loaded_pact).to be_instance_of ConsumerContract
|
26
|
+
it "should have a provider" do
|
27
|
+
expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
|
28
|
+
end
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
context "with old 'producer' key" do
|
32
|
+
let(:string) { File.read('./spec/support/a_consumer-a_producer.json')}
|
33
|
+
it "should create a Pact" do
|
34
|
+
expect(loaded_pact).to be_instance_of ConsumerContract
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
it "should have interactions" do
|
38
|
+
expect(loaded_pact.interactions).to be_instance_of Array
|
39
|
+
end
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
41
|
+
it "should have a consumer" do
|
42
|
+
expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
|
43
|
+
end
|
47
44
|
|
48
|
-
|
49
|
-
|
45
|
+
it "should have a provider" do
|
46
|
+
expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
|
47
|
+
expect(loaded_pact.provider.name).to eq "an old producer"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should have a provider_state" do
|
51
|
+
expect(loaded_pact.interactions.first.provider_state).to eq 'state one'
|
52
|
+
end
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
@@ -3,22 +3,13 @@ require 'pact/consumer_contract/file_name'
|
|
3
3
|
module Pact
|
4
4
|
describe FileName do
|
5
5
|
describe "file_path" do
|
6
|
-
|
7
|
-
subject { FileName.file_path 'foo', 'bar', 'tmp/pacts' }
|
6
|
+
let(:subject) { FileName.file_path 'foo', 'bar', 'tmp/pacts' }
|
8
7
|
it { is_expected.to eq 'tmp/pacts/foo-bar.json' }
|
9
8
|
|
10
9
|
context "when unique is true" do
|
11
|
-
subject { FileName.file_path 'foo', 'bar', 'tmp/pacts', unique: true }
|
10
|
+
let(:subject) { FileName.file_path 'foo', 'bar', 'tmp/pacts', unique: true }
|
12
11
|
it { is_expected.to match %r{tmp/pacts/foo-bar-\d+.json} }
|
13
12
|
end
|
14
|
-
|
15
|
-
context "when the path includes backslashes" do
|
16
|
-
subject { FileName.file_path 'foo', 'bar', 'c:\tmp\pacts' }
|
17
|
-
|
18
|
-
it "changes them to forward slashes" do
|
19
|
-
expect(subject).to eq "c:/tmp/pacts/foo-bar.json"
|
20
|
-
end
|
21
|
-
end
|
22
13
|
end
|
23
14
|
end
|
24
15
|
end
|
data/tasks/spec.rake
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.99.alpha.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-
|
15
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|
@@ -210,34 +210,6 @@ dependencies:
|
|
210
210
|
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
212
|
version: '0'
|
213
|
-
- !ruby/object:Gem::Dependency
|
214
|
-
name: conventional-changelog
|
215
|
-
requirement: !ruby/object:Gem::Requirement
|
216
|
-
requirements:
|
217
|
-
- - "~>"
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version: '1.3'
|
220
|
-
type: :development
|
221
|
-
prerelease: false
|
222
|
-
version_requirements: !ruby/object:Gem::Requirement
|
223
|
-
requirements:
|
224
|
-
- - "~>"
|
225
|
-
- !ruby/object:Gem::Version
|
226
|
-
version: '1.3'
|
227
|
-
- !ruby/object:Gem::Dependency
|
228
|
-
name: bump
|
229
|
-
requirement: !ruby/object:Gem::Requirement
|
230
|
-
requirements:
|
231
|
-
- - "~>"
|
232
|
-
- !ruby/object:Gem::Version
|
233
|
-
version: '0.5'
|
234
|
-
type: :development
|
235
|
-
prerelease: false
|
236
|
-
version_requirements: !ruby/object:Gem::Requirement
|
237
|
-
requirements:
|
238
|
-
- - "~>"
|
239
|
-
- !ruby/object:Gem::Version
|
240
|
-
version: '0.5'
|
241
213
|
description:
|
242
214
|
email:
|
243
215
|
- james.fraser@alumni.swinburne.edu
|
@@ -268,6 +240,7 @@ files:
|
|
268
240
|
- lib/pact/consumer_contract/consumer_contract.rb
|
269
241
|
- lib/pact/consumer_contract/file_name.rb
|
270
242
|
- lib/pact/consumer_contract/headers.rb
|
243
|
+
- lib/pact/consumer_contract/http_consumer_contract_parser.rb
|
271
244
|
- lib/pact/consumer_contract/interaction.rb
|
272
245
|
- lib/pact/consumer_contract/pact_file.rb
|
273
246
|
- lib/pact/consumer_contract/query.rb
|
@@ -320,7 +293,6 @@ files:
|
|
320
293
|
- lib/pact/term.rb
|
321
294
|
- lib/tasks/pact.rake
|
322
295
|
- pact-support.gemspec
|
323
|
-
- script/release.sh
|
324
296
|
- script/update-pact-specification-v2
|
325
297
|
- spec/fixtures/interaction-with-matching-rules.json
|
326
298
|
- spec/integration/matching_rules_extract_and_merge_spec.rb
|
@@ -391,7 +363,6 @@ files:
|
|
391
363
|
- spec/support/test_app_fail.json
|
392
364
|
- spec/support/test_app_pass.json
|
393
365
|
- spec/support/test_app_with_right_content_type_differ.json
|
394
|
-
- tasks/release.rake
|
395
366
|
- tasks/spec.rake
|
396
367
|
homepage: https://github.com/bethesque/pact-support
|
397
368
|
licenses:
|
@@ -408,9 +379,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
408
379
|
version: '2.0'
|
409
380
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
410
381
|
requirements:
|
411
|
-
- - "
|
382
|
+
- - ">"
|
412
383
|
- !ruby/object:Gem::Version
|
413
|
-
version:
|
384
|
+
version: 1.3.1
|
414
385
|
requirements: []
|
415
386
|
rubyforge_project:
|
416
387
|
rubygems_version: 2.4.5.2
|
data/script/release.sh
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
set -e
|
3
|
-
|
4
|
-
git checkout -- lib/pact/support/version.rb
|
5
|
-
bundle exec bump ${1:-minor} --no-commit
|
6
|
-
bundle exec rake generate_changelog
|
7
|
-
git add CHANGELOG.md lib/pact/support/version.rb
|
8
|
-
git commit -m "Releasing version $(ruby -r ./lib/pact/support/version.rb -e "puts Pact::Support::VERSION")"
|
9
|
-
bundle exec rake release
|