Skip to content

Commit 5574a60

Browse files
authored
Merge pull request pact-foundation#54 from iamvery/ruby-2-5
chore: build against Ruby 2.5
2 parents 8ef6311 + 6223c83 commit 5574a60

8 files changed

+58
-20
lines changed

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ rvm:
44
- 2.1.8
55
- 2.2.4
66
- 2.3.1
7+
- 2.4.3
8+
- 2.5.0
79
- jruby-9.1.13.0
810
gemfile:
911
- gemfiles/default.gemfile
@@ -19,5 +21,9 @@ matrix:
1921
gemfile: gemfiles/ruby_under_22.gemfile
2022
- rvm: 2.3.1
2123
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
2228
- rvm: jruby-9.1.13.0
2329
gemfile: gemfiles/ruby_under_22.gemfile

pact-support.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Gem::Specification.new do |gem|
2828
gem.add_runtime_dependency 'awesome_print', '~> 1.1'
2929

3030
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'
3232
gem.add_development_dependency 'pry'
3333
gem.add_development_dependency 'fakefs', '~> 0.11.2'
3434
gem.add_development_dependency 'hashie', '~> 2.0'

spec/lib/pact/matchers/list_diff_formatter_spec.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'spec_helper'
22
require 'pact/matchers/list_diff_formatter'
33
require 'pact/matchers/matchers'
4+
require 'support/ruby_version_helpers'
45

56
# Needed to stop the ai printing in color
67
# TODO: fix this!
@@ -23,7 +24,7 @@ module Matchers
2324
\tExpected type:
2425
\t\tString
2526
\tActual type:
26-
\t\tFixnum
27+
\t\t#{RubyVersionHelpers.numeric_type}
2728
EOS
2829
}
2930

spec/lib/pact/matchers/matchers_messages_mismatched_value_spec.rb

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
require 'spec_helper'
22
require 'pact/matchers'
33
require 'pact/consumer_contract/headers'
4+
require 'support/ruby_version_helpers'
45

56
module Pact::Matchers
67

78
describe Pact::Matchers do
89
include Pact::Matchers
10+
extend RubyVersionHelpers
911

1012
describe "diff" do
1113
STRING = "foo"
@@ -23,7 +25,7 @@ module Pact::Matchers
2325
[STRING, ARRAY, "Expected \"foo\" but got an Array at <path>"],
2426
[Pact.like(STRING), "bar", nil],
2527
[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>"],
2729
[Pact.like(STRING), FLOAT, "Expected a String (like \"foo\") but got a Float (1.0) at <path>"],
2830
[Pact.like(STRING), HASH, "Expected a String (like \"foo\") but got a Hash at <path>"],
2931
[Pact.like(STRING), ARRAY, "Expected a String (like \"foo\") but got an Array at <path>"],
@@ -34,22 +36,22 @@ module Pact::Matchers
3436
[INT, HASH, "Expected 1 but got a Hash at <path>"],
3537
[INT, ARRAY, "Expected 1 but got an Array at <path>"],
3638
[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>"],
4244
[HASH, HASH, nil],
4345
[HASH, nil, "Expected a Hash but got nil at <path>"],
4446
[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>"],
4648
[HASH, FLOAT, "Expected a Hash but got a Float (1.0) at <path>"],
4749
[HASH, ARRAY, "Expected a Hash but got an Array at <path>"],
4850
[Pact.like(HASH), STRING, "Expected a Hash but got a String (\"foo\") at <path>"],
4951
[ARRAY, ARRAY, nil],
5052
[ARRAY, nil, "Expected an Array but got nil at <path>"],
5153
[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>"],
5355
[ARRAY, FLOAT, "Expected an Array but got a Float (1.0) at <path>"],
5456
[ARRAY, HASH, "Expected an Array but got a Hash at <path>"]
5557
]

spec/lib/pact/matchers/matchers_messages_regexp_spec.rb

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
require 'spec_helper'
22
require 'pact/matchers'
33
require 'pact/consumer_contract/headers'
4+
require 'support/ruby_version_helpers'
45

56
module Pact::Matchers
67

78
describe Pact::Matchers do
89
include Pact::Matchers
10+
include RubyVersionHelpers
911

1012
describe "diff" do
1113
STRING = "foo"
@@ -29,10 +31,10 @@ module Pact::Matchers
2931
end
3032
end
3133

32-
context "when the actual is a Fixnum" do
34+
context "when the actual is a numeric" do
3335
let(:actual) { INT }
3436
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>"
3638
end
3739
end
3840

@@ -43,10 +45,10 @@ module Pact::Matchers
4345
end
4446
end
4547

46-
context "when the actual is a Fixnum" do
48+
context "when the actual is a numeric" do
4749
let(:actual) { INT }
4850
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>"
5052
end
5153
end
5254

@@ -68,10 +70,10 @@ module Pact::Matchers
6870
end
6971
end
7072

71-
context "when the actual is a Fixnum" do
73+
context "when the actual is a numeric" do
7274
let(:actual) { INT }
7375
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>"
7577
end
7678
end
7779

@@ -82,10 +84,10 @@ module Pact::Matchers
8284
end
8385
end
8486

85-
context "when the actual is a Fixnum" do
87+
context "when the actual is a numeric" do
8688
let(:actual) { INT }
8789
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>"
8991
end
9092
end
9193

spec/lib/pact/matchers/type_difference_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
require 'spec_helper'
22
require 'pact/matchers/type_difference'
3+
require 'support/ruby_version_helpers'
34

45
module Pact
56
module Matchers
67
describe TypeDifference do
8+
include RubyVersionHelpers
79

810
describe "#as_json" do
911

@@ -21,7 +23,7 @@ module Matchers
2123
end
2224

2325
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 } }
2527

2628
it "uses the key ACTUAL_TYPE" do
2729
expect(subject.as_json).to eq(expected_hash)

spec/lib/pact/matchers/unix_diff_formatter_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
require 'pact/matchers/unix_diff_formatter'
33
require 'pact/matchers/expected_type'
44
require 'pact/matchers/actual_type'
5+
require 'support/ruby_version_helpers'
56

67
module Pact
78
module Matchers
89
describe UnixDiffFormatter do
10+
include RubyVersionHelpers
911

1012
describe ".call" do
1113

@@ -35,7 +37,7 @@ module Matchers
3537
let(:output) { <<-EOF
3638
{
3739
- "thing": String
38-
+ "thing": Fixnum
40+
+ "thing": #{numeric_type}
3941
}
4042
EOF
4143
}

spec/support/ruby_version_helpers.rb

+23
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)