pact-support 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6011a979ee41a74c84ff53727a675089c3278c6
4
- data.tar.gz: 18ab072a5b58bb69d13e0814fda0652f36820b3b
3
+ metadata.gz: 29ed91c9b2caf2bd2bee8e271b0c8b8279dca555
4
+ data.tar.gz: cd04946d224d0795354216e1a0fa0ebfe7f04fc6
5
5
  SHA512:
6
- metadata.gz: 3473ea8471e9d9fe92d560f6553ec564624e2bff1d06db46e7eca79ed679503753e5d47eb82de4197cebfba87a9a7efd32758dea85190ee11adfb185eb482a1a
7
- data.tar.gz: e68d4fe6e17e256ffa6cba10fd04a9b5e8a26249d3a9046a4b2e5ebd8f180e639724eb120b9b23ecde9a7c53635e23cd54debdc51b12825846aba58036a8c40e
6
+ metadata.gz: de1d26bb0d8e86ea532afb67d1f2a721d02e3a52b5cc22e7818e1e867bf18c1bc43a3b2945af08dd5e039855154d9a5e92666d7129137bee1e28119cd9e785e2
7
+ data.tar.gz: 871db2f07690d2036e0df5d2914effd3bf1d7ba980d90e3c6dd74a4ca609db2cac60a6f025e49c0cc9fc618d819bc738149cfb77374136315fd4a8557fb41f8e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 0.5.0 (10 July 2015)
6
+
7
+ * 9451bf4 - Created helper methods for Pact::Term, SomethingLike and ArrayLike (Beth Skurrie, Fri Jul 10 11:44:45 2015 +1000)
8
+
5
9
  ### 0.4.4 (9 July 2015)
6
10
 
7
11
  * 6d9be6e - Create no rules for exact matching (Beth Skurrie, Thu Jul 9 14:28:56 2015 +1000)
@@ -0,0 +1,33 @@
1
+ require 'pact/something_like'
2
+ require 'pact/term'
3
+ require 'pact/array_like'
4
+
5
+ # Protected, exposed through Pact.term and Pact.like, and included in Pact::Consumer::RSpec
6
+
7
+ module Pact
8
+ module Helpers
9
+
10
+ def self.included(base)
11
+ base.extend(self)
12
+ end
13
+
14
+ def term arg1, arg2 = nil
15
+ case arg1
16
+ when Hash then Pact::Term.new(arg1)
17
+ when Regexp then Pact::Term.new(matcher: arg1, generate: arg2)
18
+ when String then Pact::Term.new(matcher: arg2, generate: arg1)
19
+ else
20
+ raise ArgumentError, "Cannot create a Pact::Term from arguments #{arg1.inspect} and #{arg2.inspect}. Please provide a Regexp and a String."
21
+ end
22
+ end
23
+
24
+ def like content
25
+ Pact::SomethingLike.new(content)
26
+ end
27
+
28
+ def each_like content, options = {}
29
+ Pact::ArrayLike.new(content, options)
30
+ end
31
+
32
+ end
33
+ end
data/lib/pact/support.rb CHANGED
@@ -3,7 +3,11 @@ require 'pact/consumer_contract'
3
3
  require 'pact/matchers'
4
4
  require 'pact/logging'
5
5
  require 'pact/term'
6
- require 'pact/something_like'
6
+ require 'pact/helpers'
7
7
  require 'pact/configuration'
8
8
  require 'pact/reification'
9
9
  require 'pact/rspec'
10
+
11
+ module Pact
12
+ include Pact::Helpers
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "0.4.4"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -0,0 +1,48 @@
1
+ require 'pact/helpers'
2
+
3
+ module Pact
4
+ describe Helpers do
5
+
6
+ include Pact::Helpers
7
+
8
+ describe "#term" do
9
+
10
+ context "with a Hash argument" do
11
+ it "creates a Pact::Term" do
12
+ expect(term(generate: 'food', matcher: /foo/)).to eq Pact::Term.new(generate: 'food', matcher: /foo/)
13
+ end
14
+ end
15
+
16
+ context "with a Regexp and a String" do
17
+ it "creates a Pact::Term" do
18
+ expect(term(/foo/, 'food')).to eq Pact::Term.new(generate: 'food', matcher: /foo/)
19
+ end
20
+ end
21
+
22
+ context "with a String and a Regexp" do
23
+ it "creates a Pact::Term" do
24
+ expect(term('food', /foo/)).to eq Pact::Term.new(generate: 'food', matcher: /foo/)
25
+ end
26
+ end
27
+
28
+ context "with anything else" do
29
+ it "raises an ArgumentError" do
30
+ expect{ term(1, /foo/) }.to raise_error(ArgumentError, /Cannot create.*1.*foo/)
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#like" do
36
+ it "creates a Pact::SomethingLike" do
37
+ expect(like(1)).to eq Pact::SomethingLike.new(1)
38
+ end
39
+ end
40
+
41
+ describe "#each_like" do
42
+ it "creates a Pact::ArrayLike" do
43
+ expect(each_like(1)).to eq Pact::ArrayLike.new(1)
44
+ expect(each_like(1, min: 2)).to eq Pact::ArrayLike.new(1, min: 2)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,9 @@
1
+ require 'pact/support'
2
+
3
+ describe Pact do
4
+
5
+ it "includes the Pact::Helpers" do
6
+ expect(Pact).to respond_to(:each_like)
7
+ end
8
+
9
+ 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: 0.4.4
4
+ version: 0.5.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: 2015-07-09 00:00:00.000000000 Z
15
+ date: 2015-07-10 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -246,6 +246,7 @@ files:
246
246
  - lib/pact/consumer_contract/response.rb
247
247
  - lib/pact/consumer_contract/service_consumer.rb
248
248
  - lib/pact/consumer_contract/service_provider.rb
249
+ - lib/pact/helpers.rb
249
250
  - lib/pact/logging.rb
250
251
  - lib/pact/matchers.rb
251
252
  - lib/pact/matchers/actual_type.rb
@@ -299,6 +300,7 @@ files:
299
300
  - spec/lib/pact/consumer_contract/query_string_spec.rb
300
301
  - spec/lib/pact/consumer_contract/request_spec.rb
301
302
  - spec/lib/pact/consumer_contract/response_spec.rb
303
+ - spec/lib/pact/helpers_spec.rb
302
304
  - spec/lib/pact/matchers/differ_spec.rb
303
305
  - spec/lib/pact/matchers/difference_spec.rb
304
306
  - spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
@@ -322,6 +324,7 @@ files:
322
324
  - spec/lib/pact/shared/request_spec.rb
323
325
  - spec/lib/pact/shared/text_differ_spec.rb
324
326
  - spec/lib/pact/something_like_spec.rb
327
+ - spec/lib/pact/support_spec.rb
325
328
  - spec/lib/pact/symbolize_keys_spec.rb
326
329
  - spec/lib/pact/term_spec.rb
327
330
  - spec/pact_specification/compliance-2.0.rb
@@ -387,6 +390,7 @@ test_files:
387
390
  - spec/lib/pact/consumer_contract/query_string_spec.rb
388
391
  - spec/lib/pact/consumer_contract/request_spec.rb
389
392
  - spec/lib/pact/consumer_contract/response_spec.rb
393
+ - spec/lib/pact/helpers_spec.rb
390
394
  - spec/lib/pact/matchers/differ_spec.rb
391
395
  - spec/lib/pact/matchers/difference_spec.rb
392
396
  - spec/lib/pact/matchers/embedded_diff_formatter_spec.rb
@@ -410,6 +414,7 @@ test_files:
410
414
  - spec/lib/pact/shared/request_spec.rb
411
415
  - spec/lib/pact/shared/text_differ_spec.rb
412
416
  - spec/lib/pact/something_like_spec.rb
417
+ - spec/lib/pact/support_spec.rb
413
418
  - spec/lib/pact/symbolize_keys_spec.rb
414
419
  - spec/lib/pact/term_spec.rb
415
420
  - spec/pact_specification/compliance-2.0.rb