pact-support 1.3.0.alpha.2 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 252461d85c1d41233fbc3fd74d9a4f6a3628ac42
4
- data.tar.gz: c3be8741ec52e41666815d821d7575f39f20f0b2
3
+ metadata.gz: 6bc207d989ed7eac517729f4664305316b83b64b
4
+ data.tar.gz: 5e1a83e3f0d51d01ef712ee33091ef070b926ba6
5
5
  SHA512:
6
- metadata.gz: 7ac6f0ce52bb4956369e47a406fefa75fba3ec9b300ad35ed95e76b02ae46f8a9eaf8952dd6c18092ff8e372a941bd3f3d5994b290eec23f71d7db69c7ad2f1b
7
- data.tar.gz: 3f9dea60c0342fbaf4ac68ba38dcee5623510f61220984a3870b035659eddfb7398190a18f8e127f166a29859e78f727425544f416718ecf4e3cf229950e8a77
6
+ metadata.gz: fc3a3af1fa03f3d920741bd65e0bf83047bc29eddea3109d755cababd978d0de9e26f2c1e3c944f79623b2d41ef06416184357c2247d62b6e072b5059c81d33c
7
+ data.tar.gz: 286126e9c5cc0e5c617e0c1cb324a5453a82b8b37f34dc367ded266dbb19618d1f7cbf7f73029b6ed83a3850cb2c9ee325caa642acf844347998d0122f407eb8
data/.travis.yml CHANGED
@@ -4,6 +4,8 @@ rvm:
4
4
  - 2.1.8
5
5
  - 2.2.4
6
6
  - 2.3.1
7
+ - 2.4.3
8
+ - 2.5.0
7
9
  - jruby-9.1.13.0
8
10
  gemfile:
9
11
  - gemfiles/default.gemfile
@@ -19,5 +21,9 @@ matrix:
19
21
  gemfile: gemfiles/ruby_under_22.gemfile
20
22
  - rvm: 2.3.1
21
23
  gemfile: gemfiles/ruby_under_22.gemfile
24
+ - rvm: 2.4.3
25
+ gemfile: gemfiles/ruby_under_22.gemfile
26
+ - rvm: 2.5.0
27
+ gemfile: gemfiles/ruby_under_22.gemfile
22
28
  - rvm: jruby-9.1.13.0
23
29
  gemfile: gemfiles/ruby_under_22.gemfile
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
- Do this to generate your change history
1
+ <a name="v1.3.0"></a>
2
+ ### v1.3.0 (2018-03-19)
2
3
 
3
- git log --pretty=format:' * %h - %s (%an, %ad)'
4
+ #### Features
5
+
6
+ * do not automatically create tmp/pacts dir ([de9e25e](/../../commit/de9e25e))
7
+
8
+
9
+ <a name="v1.2.5"></a>
10
+ ### v1.2.5 (2018-02-16)
11
+
12
+ #### Bug Fixes
13
+
14
+ * replace backslashes in pact dir path with forward slashes ([a1b5013](/../../commit/a1b5013))
4
15
 
5
16
  ### 1.2.4 (2017-10-30)
6
17
  * 80bbdcc - fix: remove unused dependency on rack-test (Beth Skurrie, Mon Oct 30 09:52:22 2017 +1100)
data/RELEASING.md CHANGED
@@ -1,15 +1,5 @@
1
1
  # Releasing
2
2
 
3
- 1. Increment the version in `lib/pact/support/version.rb`
4
- 2. Update the `CHANGELOG.md` using:
3
+ Run
5
4
 
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
5
+ script/release.sh [major|minor|patch] # default is minor
@@ -72,8 +72,8 @@ module Pact
72
72
 
73
73
  # Should this be deprecated in favour of register_diff_formatter???
74
74
  def diff_formatter= diff_formatter
75
- register_diff_formatter /.*/, diff_formatter
76
- register_diff_formatter nil, diff_formatter
75
+ register_diff_formatter(/.*/, diff_formatter)
76
+ register_diff_formatter(nil, diff_formatter)
77
77
  end
78
78
 
79
79
  def register_diff_formatter content_type, diff_formatter
@@ -174,11 +174,9 @@ module Pact
174
174
 
175
175
  def self.configure
176
176
  yield configuration
177
- FileUtils::mkdir_p configuration.tmp_dir
178
177
  end
179
178
 
180
179
  def self.clear_configuration
181
180
  @configuration = nil
182
181
  end
183
-
184
182
  end
@@ -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'
14
13
 
15
14
  module Pact
15
+
16
16
  class ConsumerContract
17
17
 
18
18
  include SymbolizeKeys
@@ -29,19 +29,13 @@ 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
-
40
32
  def self.from_hash(hash)
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}")
33
+ hash = symbolize_keys(hash)
34
+ new(
35
+ :consumer => ServiceConsumer.from_hash(hash[:consumer]),
36
+ :provider => ServiceProvider.from_hash(hash[:provider]),
37
+ :interactions => hash[:interactions].collect { |h| Interaction.from_hash(h)}
38
+ )
45
39
  end
46
40
 
47
41
  def self.from_json string
@@ -60,9 +54,9 @@ module Pact
60
54
  def find_interaction criteria
61
55
  interactions = find_interactions criteria
62
56
  if interactions.size == 0
63
- raise Pact::Error.new("Could not find interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}.")
57
+ raise "Could not find interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}."
64
58
  elsif interactions.size > 1
65
- raise Pact::Error.new("Found more than 1 interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}.")
59
+ raise "Found more than 1 interaction matching #{criteria} in pact file between #{consumer.name} and #{provider.name}."
66
60
  end
67
61
  interactions.first
68
62
  end
@@ -8,11 +8,15 @@ 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(pact_dir, file_name(consumer_name, provider_name, options))
11
+ File.join(windows_safe(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
17
21
  end
18
22
  end
@@ -6,7 +6,7 @@ require 'pact/matching_rules'
6
6
  require 'pact/errors'
7
7
 
8
8
  module Pact
9
- class Interaction
9
+ class Interaction
10
10
  include ActiveSupportSupport
11
11
  include SymbolizeKeys
12
12
 
@@ -36,10 +36,6 @@ module Pact
36
36
  }
37
37
  end
38
38
 
39
- def http?
40
- true
41
- end
42
-
43
39
  def validate!
44
40
  raise Pact::InvalidInteractionError.new(self) unless description && request && response
45
41
  end
@@ -1,5 +1,4 @@
1
1
  require 'pact/shared/active_support_support'
2
- require 'pact/matchers'
3
2
 
4
3
  module Pact
5
4
  class QueryString
@@ -224,7 +224,7 @@ module Pact
224
224
  expected_desc = class_name_with_value_in_brackets(expected)
225
225
  expected_desc.gsub!("(", "(like ")
226
226
  actual_desc = class_name_with_value_in_brackets(actual)
227
- message = "Expected #{expected_desc} but got #{actual_desc} at <path>"
227
+ "Expected #{expected_desc} but got #{actual_desc} at <path>"
228
228
  end
229
229
  end
230
230
  end
@@ -13,7 +13,6 @@ module Pact
13
13
  def initialize(path)
14
14
  scanner = StringScanner.new(path)
15
15
  @path = []
16
- bracket_count = 0
17
16
  while not scanner.eos?
18
17
  if token = scanner.scan(/\$/)
19
18
  @path << token
@@ -49,10 +48,10 @@ module Pact
49
48
  @path.last << token
50
49
  end
51
50
  end
51
+ end
52
52
 
53
- def to_s
54
- path.join
55
- end
53
+ def to_s
54
+ path.join
56
55
  end
57
56
  end
58
57
  end
@@ -15,8 +15,8 @@ module Pact
15
15
  when Pact::Term, Regexp, Pact::SomethingLike, Pact::ArrayLike
16
16
  from_term(term.generate)
17
17
  when Hash
18
- term.inject({}) do |mem, (key,term)|
19
- mem[key] = from_term(term)
18
+ term.inject({}) do |mem, (key,t)|
19
+ mem[key] = from_term(t)
20
20
  mem
21
21
  end
22
22
  when Array
@@ -1,4 +1,3 @@
1
- require 'pact/matchers/matchers'
2
1
  require 'uri'
3
2
 
4
3
  module Pact
@@ -19,8 +18,8 @@ module Pact
19
18
  end
20
19
 
21
20
  def self.ensure_values_are_arrays hash
22
- hash.each_with_object({}) do | (key, value), hash |
23
- hash[key.to_s] = [*value]
21
+ hash.each_with_object({}) do | (key, value), h |
22
+ h[key.to_s] = [*value]
24
23
  end
25
24
  end
26
25
 
@@ -1,11 +1,9 @@
1
- require 'pact/matchers/matchers'
2
-
3
1
  module Pact
4
2
  class JsonDiffer
5
3
 
6
4
  extend Matchers
7
5
 
8
- # Delegates to https://github.com/bethesque/pact-support/blob/master/lib/pact/matchers/matchers.rb#L25
6
+ # Delegates to https://github.com/pact-foundation/pact-support/blob/master/lib/pact/matchers/matchers.rb#L25
9
7
  def self.call expected, actual, options = {}
10
8
  diff expected, actual, options
11
9
  end
@@ -1,4 +1,3 @@
1
- require 'pact/matchers'
2
1
  require 'pact/symbolize_keys'
3
2
  require 'pact/consumer_contract/headers'
4
3
  require 'pact/consumer_contract/query'
@@ -1,4 +1,3 @@
1
- require 'pact/matchers/matchers'
2
1
  require 'pact/matchers/difference'
3
2
 
4
3
  module Pact
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "1.3.0.alpha.2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
data/pact-support.gemspec CHANGED
@@ -28,10 +28,12 @@ Gem::Specification.new do |gem|
28
28
  gem.add_runtime_dependency 'awesome_print', '~> 1.1'
29
29
 
30
30
  gem.add_development_dependency 'rake', '~> 10.0.3'
31
- gem.add_development_dependency 'webmock', '~> 2.0.0'
31
+ gem.add_development_dependency 'webmock', '~> 3.3'
32
32
  gem.add_development_dependency 'pry'
33
33
  gem.add_development_dependency 'fakefs', '~> 0.11.2'
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'
37
39
  end
data/script/release.sh ADDED
@@ -0,0 +1,9 @@
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
@@ -3,53 +3,50 @@ require 'pact/consumer_contract'
3
3
 
4
4
  module Pact
5
5
  describe ConsumerContract do
6
- describe ".from_json" do
7
6
 
7
+ describe ".from_json" do
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"} }' }
9
11
 
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"} }' }
13
-
14
- it "should create a Pact" do
15
- expect(loaded_pact).to be_instance_of ConsumerContract
16
- end
12
+ it "should create a Pact" do
13
+ expect(loaded_pact).to be_instance_of ConsumerContract
14
+ end
17
15
 
18
- it "should have interactions" do
19
- expect(loaded_pact.interactions).to be_instance_of Array
20
- end
16
+ it "should have interactions" do
17
+ expect(loaded_pact.interactions).to be_instance_of Array
18
+ end
21
19
 
22
- it "should have a consumer" do
23
- expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
24
- end
20
+ it "should have a consumer" do
21
+ expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
22
+ end
25
23
 
26
- it "should have a provider" do
27
- expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
28
- end
24
+ it "should have a provider" do
25
+ expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
29
26
  end
27
+ end
30
28
 
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
29
+ context "with old 'producer' key" do
30
+ let(:string) { File.read('./spec/support/a_consumer-a_producer.json')}
31
+ it "should create a Pact" do
32
+ expect(loaded_pact).to be_instance_of ConsumerContract
33
+ end
36
34
 
37
- it "should have interactions" do
38
- expect(loaded_pact.interactions).to be_instance_of Array
39
- end
35
+ it "should have interactions" do
36
+ expect(loaded_pact.interactions).to be_instance_of Array
37
+ end
40
38
 
41
- it "should have a consumer" do
42
- expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
43
- end
39
+ it "should have a consumer" do
40
+ expect(loaded_pact.consumer).to be_instance_of Pact::ServiceConsumer
41
+ end
44
42
 
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
43
+ it "should have a provider" do
44
+ expect(loaded_pact.provider).to be_instance_of Pact::ServiceProvider
45
+ expect(loaded_pact.provider.name).to eq "an old producer"
46
+ end
49
47
 
50
- it "should have a provider_state" do
51
- expect(loaded_pact.interactions.first.provider_state).to eq 'state one'
52
- end
48
+ it "should have a provider_state" do
49
+ expect(loaded_pact.interactions.first.provider_state).to eq 'state one'
53
50
  end
54
51
  end
55
52
  end
@@ -3,13 +3,22 @@ require 'pact/consumer_contract/file_name'
3
3
  module Pact
4
4
  describe FileName do
5
5
  describe "file_path" do
6
- let(:subject) { FileName.file_path 'foo', 'bar', 'tmp/pacts' }
6
+
7
+ subject { FileName.file_path 'foo', 'bar', 'tmp/pacts' }
7
8
  it { is_expected.to eq 'tmp/pacts/foo-bar.json' }
8
9
 
9
10
  context "when unique is true" do
10
- let(:subject) { FileName.file_path 'foo', 'bar', 'tmp/pacts', unique: true }
11
+ subject { FileName.file_path 'foo', 'bar', 'tmp/pacts', unique: true }
11
12
  it { is_expected.to match %r{tmp/pacts/foo-bar-\d+.json} }
12
13
  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
13
22
  end
14
23
  end
15
24
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'pact/matchers/list_diff_formatter'
3
3
  require 'pact/matchers/matchers'
4
+ require 'support/ruby_version_helpers'
4
5
 
5
6
  # Needed to stop the ai printing in color
6
7
  # TODO: fix this!
@@ -23,7 +24,7 @@ module Pact
23
24
  \tExpected type:
24
25
  \t\tString
25
26
  \tActual type:
26
- \t\tFixnum
27
+ \t\t#{RubyVersionHelpers.numeric_type}
27
28
  EOS
28
29
  }
29
30
 
@@ -1,11 +1,13 @@
1
1
  require 'spec_helper'
2
2
  require 'pact/matchers'
3
3
  require 'pact/consumer_contract/headers'
4
+ require 'support/ruby_version_helpers'
4
5
 
5
6
  module Pact::Matchers
6
7
 
7
8
  describe Pact::Matchers do
8
9
  include Pact::Matchers
10
+ extend RubyVersionHelpers
9
11
 
10
12
  describe "diff" do
11
13
  STRING = "foo"
@@ -23,7 +25,7 @@ module Pact::Matchers
23
25
  [STRING, ARRAY, "Expected \"foo\" but got an Array at <path>"],
24
26
  [Pact.like(STRING), "bar", nil],
25
27
  [Pact.like(STRING), nil, "Expected a String (like \"foo\") but got nil at <path>"],
26
- [Pact.like(STRING), INT, "Expected a String (like \"foo\") but got a Fixnum (1) at <path>"],
28
+ [Pact.like(STRING), INT, "Expected a String (like \"foo\") but got #{a_numeric} (1) at <path>"],
27
29
  [Pact.like(STRING), FLOAT, "Expected a String (like \"foo\") but got a Float (1.0) at <path>"],
28
30
  [Pact.like(STRING), HASH, "Expected a String (like \"foo\") but got a Hash at <path>"],
29
31
  [Pact.like(STRING), ARRAY, "Expected a String (like \"foo\") but got an Array at <path>"],
@@ -34,22 +36,22 @@ module Pact::Matchers
34
36
  [INT, HASH, "Expected 1 but got a Hash at <path>"],
35
37
  [INT, ARRAY, "Expected 1 but got an Array at <path>"],
36
38
  [Pact.like(INT), 2, nil],
37
- [Pact.like(INT), nil, "Expected a Fixnum (like 1) but got nil at <path>"],
38
- [Pact.like(INT), STRING, "Expected a Fixnum (like 1) but got a String (\"foo\") at <path>"],
39
- [Pact.like(INT), FLOAT, "Expected a Fixnum (like 1) but got a Float (1.0) at <path>"],
40
- [Pact.like(INT), HASH, "Expected a Fixnum (like 1) but got a Hash at <path>"],
41
- [Pact.like(INT), ARRAY, "Expected a Fixnum (like 1) but got an Array at <path>"],
39
+ [Pact.like(INT), nil, "Expected #{a_numeric} (like 1) but got nil at <path>"],
40
+ [Pact.like(INT), STRING, "Expected #{a_numeric} (like 1) but got a String (\"foo\") at <path>"],
41
+ [Pact.like(INT), FLOAT, "Expected #{a_numeric} (like 1) but got a Float (1.0) at <path>"],
42
+ [Pact.like(INT), HASH, "Expected #{a_numeric} (like 1) but got a Hash at <path>"],
43
+ [Pact.like(INT), ARRAY, "Expected #{a_numeric} (like 1) but got an Array at <path>"],
42
44
  [HASH, HASH, nil],
43
45
  [HASH, nil, "Expected a Hash but got nil at <path>"],
44
46
  [HASH, STRING, "Expected a Hash but got a String (\"foo\") at <path>"],
45
- [HASH, INT, "Expected a Hash but got a Fixnum (1) at <path>"],
47
+ [HASH, INT, "Expected a Hash but got #{a_numeric} (1) at <path>"],
46
48
  [HASH, FLOAT, "Expected a Hash but got a Float (1.0) at <path>"],
47
49
  [HASH, ARRAY, "Expected a Hash but got an Array at <path>"],
48
50
  [Pact.like(HASH), STRING, "Expected a Hash but got a String (\"foo\") at <path>"],
49
51
  [ARRAY, ARRAY, nil],
50
52
  [ARRAY, nil, "Expected an Array but got nil at <path>"],
51
53
  [ARRAY, STRING, "Expected an Array but got a String (\"foo\") at <path>"],
52
- [ARRAY, INT, "Expected an Array but got a Fixnum (1) at <path>"],
54
+ [ARRAY, INT, "Expected an Array but got #{a_numeric} (1) at <path>"],
53
55
  [ARRAY, FLOAT, "Expected an Array but got a Float (1.0) at <path>"],
54
56
  [ARRAY, HASH, "Expected an Array but got a Hash at <path>"]
55
57
  ]
@@ -1,11 +1,13 @@
1
1
  require 'spec_helper'
2
2
  require 'pact/matchers'
3
3
  require 'pact/consumer_contract/headers'
4
+ require 'support/ruby_version_helpers'
4
5
 
5
6
  module Pact::Matchers
6
7
 
7
8
  describe Pact::Matchers do
8
9
  include Pact::Matchers
10
+ include RubyVersionHelpers
9
11
 
10
12
  describe "diff" do
11
13
  STRING = "foo"
@@ -29,10 +31,10 @@ module Pact::Matchers
29
31
  end
30
32
  end
31
33
 
32
- context "when the actual is a Fixnum" do
34
+ context "when the actual is a numeric" do
33
35
  let(:actual) { INT }
34
36
  it "returns a message" do
35
- expect(difference[:thing].message).to eq "Expected a String matching /foo/ (like \"food\") but got a Fixnum (1) at <path>"
37
+ expect(difference[:thing].message).to eq "Expected a String matching /foo/ (like \"food\") but got #{a_numeric} (1) at <path>"
36
38
  end
37
39
  end
38
40
 
@@ -43,10 +45,10 @@ module Pact::Matchers
43
45
  end
44
46
  end
45
47
 
46
- context "when the actual is a Fixnum" do
48
+ context "when the actual is a numeric" do
47
49
  let(:actual) { INT }
48
50
  it "returns a message" do
49
- expect(difference[:thing].message).to eq "Expected a String matching /foo/ (like \"food\") but got a Fixnum (1) at <path>"
51
+ expect(difference[:thing].message).to eq "Expected a String matching /foo/ (like \"food\") but got #{a_numeric} (1) at <path>"
50
52
  end
51
53
  end
52
54
 
@@ -68,10 +70,10 @@ module Pact::Matchers
68
70
  end
69
71
  end
70
72
 
71
- context "when the actual is a Fixnum" do
73
+ context "when the actual is a numeric" do
72
74
  let(:actual) { INT }
73
75
  it "returns a message" do
74
- expect(difference[:thing].message).to eq "Expected a String matching /foo/ but got a Fixnum (1) at <path>"
76
+ expect(difference[:thing].message).to eq "Expected a String matching /foo/ but got #{a_numeric} (1) at <path>"
75
77
  end
76
78
  end
77
79
 
@@ -82,10 +84,10 @@ module Pact::Matchers
82
84
  end
83
85
  end
84
86
 
85
- context "when the actual is a Fixnum" do
87
+ context "when the actual is a numeric" do
86
88
  let(:actual) { INT }
87
89
  it "returns a message" do
88
- expect(difference[:thing].message).to eq "Expected a String matching /foo/ but got a Fixnum (1) at <path>"
90
+ expect(difference[:thing].message).to eq "Expected a String matching /foo/ but got #{a_numeric} (1) at <path>"
89
91
  end
90
92
  end
91
93
 
@@ -1,9 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'pact/matchers/type_difference'
3
+ require 'support/ruby_version_helpers'
3
4
 
4
5
  module Pact
5
6
  module Matchers
6
7
  describe TypeDifference do
8
+ include RubyVersionHelpers
7
9
 
8
10
  describe "#as_json" do
9
11
 
@@ -21,7 +23,7 @@ module Pact
21
23
  end
22
24
 
23
25
  context "when the actual is an ActualType" do
24
- let(:expected_hash) { {:EXPECTED_TYPE => "String", :ACTUAL_TYPE => "Fixnum" } }
26
+ let(:expected_hash) { {:EXPECTED_TYPE => "String", :ACTUAL_TYPE => numeric_type.to_s } }
25
27
 
26
28
  it "uses the key ACTUAL_TYPE" do
27
29
  expect(subject.as_json).to eq(expected_hash)
@@ -2,10 +2,12 @@ require 'spec_helper'
2
2
  require 'pact/matchers/unix_diff_formatter'
3
3
  require 'pact/matchers/expected_type'
4
4
  require 'pact/matchers/actual_type'
5
+ require 'support/ruby_version_helpers'
5
6
 
6
7
  module Pact
7
8
  module Matchers
8
9
  describe UnixDiffFormatter do
10
+ include RubyVersionHelpers
9
11
 
10
12
  describe ".call" do
11
13
 
@@ -35,7 +37,7 @@ module Pact
35
37
  let(:output) { <<-EOF
36
38
  {
37
39
  - "thing": String
38
- + "thing": Fixnum
40
+ + "thing": #{numeric_type}
39
41
  }
40
42
  EOF
41
43
  }
@@ -0,0 +1,23 @@
1
+ module RubyVersionHelpers
2
+ RUBY_2_4 = Gem::Version.new('2.4.0')
3
+ CURRENT_RUBY = Gem::Version.new(RUBY_VERSION)
4
+
5
+ def numeric_type
6
+ if CURRENT_RUBY < RUBY_2_4
7
+ Fixnum
8
+ else
9
+ Integer
10
+ end
11
+ end
12
+ module_function :numeric_type
13
+
14
+ def a_numeric
15
+ type = numeric_type
16
+ if type == Integer
17
+ "an #{type}"
18
+ else
19
+ "a #{type}"
20
+ end
21
+ end
22
+ module_function :a_numeric
23
+ end
@@ -0,0 +1,5 @@
1
+ task :generate_changelog do
2
+ require 'pact/support/version'
3
+ require 'conventional_changelog'
4
+ ConventionalChangelog::Generator.new.generate! version: "v#{Pact::Support::VERSION}"
5
+ end
data/tasks/spec.rake CHANGED
@@ -12,3 +12,4 @@ task :spec_with_active_support => [:set_active_support_on] do
12
12
  end
13
13
 
14
14
  task :default => [:spec, :spec_with_active_support]
15
+
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.3.0.alpha.2
4
+ version: 1.3.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-08 00:00:00.000000000 Z
15
+ date: 2018-03-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -132,14 +132,14 @@ dependencies:
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: 2.0.0
135
+ version: '3.3'
136
136
  type: :development
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: 2.0.0
142
+ version: '3.3'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: pry
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -210,6 +210,34 @@ 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'
213
241
  description:
214
242
  email:
215
243
  - james.fraser@alumni.swinburne.edu
@@ -240,7 +268,6 @@ files:
240
268
  - lib/pact/consumer_contract/consumer_contract.rb
241
269
  - lib/pact/consumer_contract/file_name.rb
242
270
  - lib/pact/consumer_contract/headers.rb
243
- - lib/pact/consumer_contract/http_consumer_contract_parser.rb
244
271
  - lib/pact/consumer_contract/interaction.rb
245
272
  - lib/pact/consumer_contract/pact_file.rb
246
273
  - lib/pact/consumer_contract/query.rb
@@ -293,6 +320,7 @@ files:
293
320
  - lib/pact/term.rb
294
321
  - lib/tasks/pact.rake
295
322
  - pact-support.gemspec
323
+ - script/release.sh
296
324
  - script/update-pact-specification-v2
297
325
  - spec/fixtures/interaction-with-matching-rules.json
298
326
  - spec/integration/matching_rules_extract_and_merge_spec.rb
@@ -356,6 +384,7 @@ files:
356
384
  - spec/support/markdown_pact.json
357
385
  - spec/support/missing_provider_states_output.txt
358
386
  - spec/support/options.json
387
+ - spec/support/ruby_version_helpers.rb
359
388
  - spec/support/shared_examples_for_request.rb
360
389
  - spec/support/spec_support.rb
361
390
  - spec/support/stubbing.json
@@ -363,6 +392,7 @@ files:
363
392
  - spec/support/test_app_fail.json
364
393
  - spec/support/test_app_pass.json
365
394
  - spec/support/test_app_with_right_content_type_differ.json
395
+ - tasks/release.rake
366
396
  - tasks/spec.rake
367
397
  homepage: https://github.com/bethesque/pact-support
368
398
  licenses:
@@ -379,9 +409,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
379
409
  version: '2.0'
380
410
  required_rubygems_version: !ruby/object:Gem::Requirement
381
411
  requirements:
382
- - - ">"
412
+ - - ">="
383
413
  - !ruby/object:Gem::Version
384
- version: 1.3.1
414
+ version: '0'
385
415
  requirements: []
386
416
  rubyforge_project:
387
417
  rubygems_version: 2.4.5.2
@@ -451,6 +481,7 @@ test_files:
451
481
  - spec/support/markdown_pact.json
452
482
  - spec/support/missing_provider_states_output.txt
453
483
  - spec/support/options.json
484
+ - spec/support/ruby_version_helpers.rb
454
485
  - spec/support/shared_examples_for_request.rb
455
486
  - spec/support/spec_support.rb
456
487
  - spec/support/stubbing.json
@@ -1,26 +0,0 @@
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