pact 1.0.6 → 1.0.7

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.
@@ -1,3 +1,7 @@
1
+ ### 1.0.7 (11 September 2012)
2
+
3
+ * Allow request query to be a Pact Term. [Seb Glazebrook]
4
+
1
5
  ### 1.0.6 (11 September 2012)
2
6
 
3
7
  * Made reports dir configurable [Beth Skurrie]
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact (1.0.6)
4
+ pact (1.0.7)
5
5
  awesome_print (~> 1.1.0)
6
6
  find_a_port (~> 1.0.1)
7
7
  hashie (~> 2.0)
@@ -63,7 +63,8 @@ module Pact
63
63
  path = request.path
64
64
  query = request.query
65
65
  if query && !query.empty?
66
- path += "?" + request.query
66
+ query = query.generate if query.kind_of? Pact::Term
67
+ path += "?" + query
67
68
  end
68
69
  path
69
70
  end
@@ -36,5 +36,9 @@ module Pact
36
36
  }
37
37
  end
38
38
 
39
+ def empty?
40
+ generate ? false : true
41
+ end
42
+
39
43
  end
40
44
  end
@@ -1,3 +1,3 @@
1
1
  module Pact
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -16,5 +16,35 @@ module Pact::Provider
16
16
  expect{ subject.send(:get_provider_state, 'some state', 'consumer') }.to raise_error /Could not find.*some state.*consumer.*/
17
17
  end
18
18
  end
19
+
20
+ describe 'request path' do
21
+
22
+ let(:request) { OpenStruct.new(:path => 'path', :query => query)}
23
+
24
+ before do
25
+ @path = subject.send(:request_path, request)
26
+ end
27
+
28
+ describe 'query' do
29
+
30
+ context 'string query' do
31
+
32
+ let(:query) { 'query' }
33
+
34
+ it 'gets appended to the path' do
35
+ expect(@path).to eq('path?query')
36
+ end
37
+ end
38
+
39
+ context 'Term query' do
40
+
41
+ let(:query) { Pact::Term.new(generate: 'query') }
42
+
43
+ it 'appends the Term\'s generate to the path' do
44
+ expect(@path).to eq('path?query')
45
+ end
46
+ end
47
+ end
48
+ end
19
49
  end
20
50
  end
@@ -3,6 +3,22 @@ require 'pact/request'
3
3
 
4
4
  shared_examples "a request" do
5
5
 
6
+ describe 'matching' do
7
+ let(:expected) do
8
+ Pact::Request::Expected.from_hash(
9
+ {'method' => 'get', 'path' => 'path', 'query' => /b/}
10
+ )
11
+ end
12
+
13
+ let(:actual) do
14
+ Pact::Request::Actual.from_hash({'method' => 'get', 'path' => 'path', 'query' => 'blah'})
15
+ end
16
+
17
+ it "should match" do
18
+ expect(expected.difference(actual)).to eq({})
19
+ end
20
+ end
21
+
6
22
  describe 'full_path' do
7
23
  context "with empty path" do
8
24
  subject { described_class.from_hash({:path => '', :method => 'get'}) }
@@ -32,5 +32,30 @@ module Pact
32
32
  end
33
33
  end
34
34
 
35
+ describe 'empty?' do
36
+
37
+ subject { Term.new(generate: generate, matcher: /some matcher/) }
38
+
39
+ context 'with generate' do
40
+
41
+ let(:generate) { 'generate here'}
42
+
43
+ it 'is not empty' do
44
+ expect(subject).to_not be_empty
45
+ end
46
+
47
+ end
48
+
49
+ context 'without generate' do
50
+
51
+ let(:generate) { nil }
52
+
53
+ it 'is empty' do
54
+ expect(subject).to be_empty
55
+ end
56
+ end
57
+
58
+ end
59
+
35
60
  end
36
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: