pact-support 1.3.1 → 1.4.0
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 +4 -4
- data/lib/pact/helpers.rb +3 -1
- data/lib/pact/matchers/extract_diff_messages.rb +8 -3
- data/lib/pact/matchers/unix_diff_formatter.rb +1 -1
- data/lib/pact/support/version.rb +1 -1
- data/spec/lib/pact/helpers_spec.rb +9 -9
- data/spec/lib/pact/matchers/extract_diff_messages_spec.rb +11 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d63ce6f1b637b9ec8c1aa7c097631c13134c8085
|
4
|
+
data.tar.gz: e7f099a1364dd8e6ea4da06c5e6c15e6d1b83b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fab573b4105cb73ab146e406cfddbb56508160324e639b35a287f823a1b8c1570347768ef0198dbcf7454ea9dbfef7f0a53f9e3b48c9e22f430c5cd4d45548e
|
7
|
+
data.tar.gz: 424fdc09077746fda17301499934ef326c6f1af664baac0cc08e5f3d3c318d1047a3a7a95db7b90cf82d6139da774cb579fedb0a56929aba6fdc66dbaf15ca0d
|
data/lib/pact/helpers.rb
CHANGED
@@ -37,10 +37,12 @@ module Pact
|
|
37
37
|
Pact::Term.new(generate: datetime, matcher: /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)$/)
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def like_datetime_with_milliseconds datetime
|
41
41
|
Pact::Term.new(generate: datetime, matcher: /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d{3}([+-][0-2]\d:[0-5]\d|Z)$/)
|
42
42
|
end
|
43
43
|
|
44
|
+
alias_method :like_datetime_with_miliseconds, :like_datetime_with_milliseconds
|
45
|
+
|
44
46
|
def like_date date
|
45
47
|
Pact::Term.new(generate: date, matcher: /^\d{4}-[01]\d-[0-3]\d$/)
|
46
48
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# @api public. Used by lib/pact/provider/rspec/pact_broker_formatter.rb
|
1
2
|
module Pact
|
2
3
|
module Matchers
|
3
4
|
class ExtractDiffMessages
|
@@ -13,17 +14,21 @@ module Pact
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def to_hash
|
16
|
-
|
17
|
+
to_a
|
17
18
|
end
|
18
19
|
|
19
20
|
def call
|
20
|
-
|
21
|
+
to_a
|
21
22
|
end
|
22
23
|
|
23
24
|
def to_s
|
24
25
|
diff_messages(diff).join("\n")
|
25
26
|
end
|
26
27
|
|
28
|
+
def to_a
|
29
|
+
diff_messages(diff)
|
30
|
+
end
|
31
|
+
|
27
32
|
def diff_messages obj, path = [], messages = []
|
28
33
|
case obj
|
29
34
|
when Hash then handle_hash obj, path, messages
|
@@ -51,7 +56,7 @@ module Pact
|
|
51
56
|
|
52
57
|
def handle_difference difference, path, messages
|
53
58
|
if difference.message
|
54
|
-
message =
|
59
|
+
message = difference.message
|
55
60
|
message = message.gsub("<path>", path_to_s(path))
|
56
61
|
message = message.gsub("<parent_path>", parent_path_to_s(path))
|
57
62
|
messages << message
|
@@ -17,7 +17,7 @@ module Pact
|
|
17
17
|
@actual = options.fetch(:actual, {})
|
18
18
|
@include_explanation = options.fetch(:include_explanation, true)
|
19
19
|
@differ = Pact::Matchers::Differ.new(@colour)
|
20
|
-
@messages = Pact::Matchers::ExtractDiffMessages.call(diff)
|
20
|
+
@messages = Pact::Matchers::ExtractDiffMessages.call(diff).collect{ | message| "* #{message}" }.join("\n")
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.call diff, options = {}
|
data/lib/pact/support/version.rb
CHANGED
@@ -59,7 +59,7 @@ module Pact
|
|
59
59
|
describe "#like_datetime" do
|
60
60
|
let(:datetime) { '2015-08-06T16:53:10+01:00' }
|
61
61
|
|
62
|
-
it "creates a Pact::Term with
|
62
|
+
it "creates a Pact::Term with DateTime matcher" do
|
63
63
|
expect(like_datetime(datetime)).to eq Pact::Term.new(
|
64
64
|
generate: datetime,
|
65
65
|
matcher: /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)$/
|
@@ -67,11 +67,11 @@ module Pact
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe "#
|
70
|
+
describe "#like_datetime_with_milliseconds" do
|
71
71
|
let(:datetime) { '2015-08-06T16:53:10.123+01:00' }
|
72
72
|
|
73
|
-
it "creates a Pact::Term with
|
74
|
-
expect(
|
73
|
+
it "creates a Pact::Term with DateTime and Millisecond precision matcher" do
|
74
|
+
expect(like_datetime_with_milliseconds(datetime)).to eq Pact::Term.new(
|
75
75
|
generate: datetime,
|
76
76
|
matcher: /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d{3}([+-][0-2]\d:[0-5]\d|Z)$/
|
77
77
|
)
|
@@ -81,7 +81,7 @@ module Pact
|
|
81
81
|
describe "#like_date" do
|
82
82
|
let(:date) { '2015-08-06' }
|
83
83
|
|
84
|
-
it "creates a Pact::Term with
|
84
|
+
it "creates a Pact::Term with Date matcher" do
|
85
85
|
expect(like_date(date)).to eq Pact::Term.new(
|
86
86
|
generate: date,
|
87
87
|
matcher: /^\d{4}-[01]\d-[0-3]\d$/
|
@@ -91,7 +91,7 @@ module Pact
|
|
91
91
|
describe "#like_datetime_rfc822" do
|
92
92
|
context "Day is Tue" do
|
93
93
|
let(:datetime) { 'Tue, 04 Apr 2017 19:03:19 +0000' }
|
94
|
-
it "creates a Pact::Term with a
|
94
|
+
it "creates a Pact::Term with a rfc822 matcher" do
|
95
95
|
expect(like_datetime_rfc822(datetime)).to eq Pact::Term.new(
|
96
96
|
generate: datetime,
|
97
97
|
matcher: /(?x)(Mon|Tue|Wed|Thu|Fri|Sat|Sun),
|
@@ -103,7 +103,7 @@ module Pact
|
|
103
103
|
|
104
104
|
context "Day is Sun" do
|
105
105
|
let(:datetime) { 'Sun, 09 Apr 2017 19:03:19 +0000' }
|
106
|
-
it "creates a Pact::Term with a
|
106
|
+
it "creates a Pact::Term with a rfc822 matcher" do
|
107
107
|
expect(like_datetime_rfc822(datetime)).to eq Pact::Term.new(
|
108
108
|
generate: datetime,
|
109
109
|
matcher: /(?x)(Mon|Tue|Wed|Thu|Fri|Sat|Sun),
|
@@ -115,7 +115,7 @@ module Pact
|
|
115
115
|
|
116
116
|
context "Month is Jan" do
|
117
117
|
let(:datetime) { 'Mon, 02 Jan 2017 19:03:19 +0000' }
|
118
|
-
it "creates a Pact::Term with a
|
118
|
+
it "creates a Pact::Term with a rfc822 matcher" do
|
119
119
|
expect(like_datetime_rfc822(datetime)).to eq Pact::Term.new(
|
120
120
|
generate: datetime,
|
121
121
|
matcher: /(?x)(Mon|Tue|Wed|Thu|Fri|Sat|Sun),
|
@@ -127,7 +127,7 @@ module Pact
|
|
127
127
|
|
128
128
|
context "Negative Offset" do
|
129
129
|
let(:datetime) { 'Mon, 31 Oct 2016 15:21:41 -0400' }
|
130
|
-
it "creates a Pact::Term with a
|
130
|
+
it "creates a Pact::Term with a rfc822 matcher" do
|
131
131
|
expect(like_datetime_rfc822(datetime)).to eq Pact::Term.new(
|
132
132
|
generate: datetime,
|
133
133
|
matcher: /(?x)(Mon|Tue|Wed|Thu|Fri|Sat|Sun),
|
@@ -4,54 +4,54 @@ module Pact
|
|
4
4
|
module Matchers
|
5
5
|
describe ExtractDiffMessages do
|
6
6
|
|
7
|
-
subject { ExtractDiffMessages.call(diff) }
|
7
|
+
subject { ExtractDiffMessages.call(diff).join("\n") }
|
8
8
|
|
9
9
|
context "<path> with a diff in a Hash" do
|
10
10
|
let(:diff) { {a: Difference.new(nil, nil, "There was a difference at <path>") } }
|
11
11
|
|
12
|
-
it { is_expected.to eq "
|
12
|
+
it { is_expected.to eq "There was a difference at $.a" }
|
13
13
|
end
|
14
14
|
|
15
15
|
context "<parent_path> with a diff in a Hash" do
|
16
16
|
let(:diff) { {a: Difference.new(nil, nil, "There was a difference at <parent_path>") } }
|
17
17
|
|
18
|
-
it { is_expected.to eq "
|
18
|
+
it { is_expected.to eq "There was a difference at $" }
|
19
19
|
end
|
20
20
|
|
21
21
|
context "<path> with a diff in a nested Hash" do
|
22
22
|
let(:diff) { {a: {b: Difference.new(nil, nil, "There was a difference at <path>")}} }
|
23
23
|
|
24
|
-
it { is_expected.to eq "
|
24
|
+
it { is_expected.to eq "There was a difference at $.a.b" }
|
25
25
|
end
|
26
26
|
|
27
27
|
context "<parent_path> with a diff in a nested Hash" do
|
28
28
|
let(:diff) { {a: {b: Difference.new(nil, nil, "There was a difference at <parent_path>")}} }
|
29
29
|
|
30
|
-
it { is_expected.to eq "
|
30
|
+
it { is_expected.to eq "There was a difference at $.a" }
|
31
31
|
end
|
32
32
|
|
33
33
|
context "<path> with a diff in an Array" do
|
34
34
|
let(:diff) { [NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <path>")] }
|
35
35
|
|
36
|
-
it { is_expected.to eq "
|
36
|
+
it { is_expected.to eq "There was a difference at $[1]" }
|
37
37
|
end
|
38
38
|
|
39
39
|
context "<parent_path> with a diff in an Array" do
|
40
40
|
let(:diff) { [NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <parent_path>")] }
|
41
41
|
|
42
|
-
it { is_expected.to eq "
|
42
|
+
it { is_expected.to eq "There was a difference at $" }
|
43
43
|
end
|
44
44
|
|
45
45
|
context "<path> with a diff in a nested Array" do
|
46
46
|
let(:diff) { [NoDiffAtIndex.new,[NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <path>")]] }
|
47
47
|
|
48
|
-
it { is_expected.to eq "
|
48
|
+
it { is_expected.to eq "There was a difference at $[1][1]" }
|
49
49
|
end
|
50
50
|
|
51
51
|
context "<parent_path> with a diff in a nested Array" do
|
52
52
|
let(:diff) { [NoDiffAtIndex.new,[NoDiffAtIndex.new, Difference.new(nil, nil, "There was a difference at <parent_path>")]] }
|
53
53
|
|
54
|
-
it { is_expected.to eq "
|
54
|
+
it { is_expected.to eq "There was a difference at $[1]" }
|
55
55
|
end
|
56
56
|
|
57
57
|
context "when there is a space in the key" do
|
@@ -59,7 +59,7 @@ module Pact
|
|
59
59
|
{"Foo Bar" => Difference.new(nil, nil, "There was a difference at <path>")}
|
60
60
|
end
|
61
61
|
|
62
|
-
it { is_expected.to eq "
|
62
|
+
it { is_expected.to eq "There was a difference at $.\"Foo Bar\"" }
|
63
63
|
end
|
64
64
|
|
65
65
|
context "with two differences" do
|
@@ -70,7 +70,7 @@ module Pact
|
|
70
70
|
}
|
71
71
|
end
|
72
72
|
|
73
|
-
it { is_expected.to eq "
|
73
|
+
it { is_expected.to eq "There was a difference at $.a\nThere was a difference at $.b" }
|
74
74
|
end
|
75
75
|
|
76
76
|
end
|
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.
|
4
|
+
version: 1.4.0
|
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-03-
|
15
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|