pact 1.1.0.rc3 → 1.1.0.rc4

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.
data/CHANGELOG.md CHANGED
@@ -1,44 +1,52 @@
1
1
  Do this to generate your change history
2
2
 
3
- git log --pretty=format:' * %h - %s (%an, %ad)'
3
+ git log --pretty=format:' * %h - %s (%an, %ad)'
4
+
5
+ ### 1.1.0.rc4 (1 May 2014)
6
+
7
+ * 5e1b78d - Display / in logs when path is empty https://github.com/realestate-com-au/pact/issues/14 (Beth, Thu May 1 22:09:29 2014 +1000)
8
+ * 01c5414 - Fixing doc generation bug where Pact::Terms were being displayed https://github.com/realestate-com-au/pact/issues/13 (Beth, Thu May 1 21:41:11 2014 +1000)
9
+ * 292a14b - Cleaning doc dir before generating new docs as per https://github.com/realestate-com-au/pact/issues/11 (Beth, Tue Apr 29 12:44:47 2014 +1000)
10
+ * 73c15dd - Changed default doc_dir to ./doc/pacts as per https://github.com/realestate-com-au/pact/issues/12 (Beth, Tue Apr 29 12:33:57 2014 +1000)
11
+ * 78ca78c - Fixed bug where log_dir was being ignored when set to a non default value (Beth, Tue Apr 29 07:50:32 2014 +1000)
4
12
 
5
13
  ### 1.1.0.rc3 (28 April 2014)
6
14
 
7
- * 41fa409 - Cleaned up consumer after spec failure message (Beth, Sun Apr 27 22:18:03 2014 +1000)
8
- * 8593fa9 - Updated zoo-app example (Beth, Sun Apr 27 20:54:51 2014 +1000)
9
- * 716e3a8 - Added standalone consumer spec and spec for VerificationGet (Beth, Thu Apr 24 10:15:17 2014 +1000)
10
- * c0f9bc6 - Copied RSpec::Expectations::Differ to Pact::Matchers::Differ - safer than trying to override behaviour (Beth, Thu Apr 24 09:17:58 2014 +
11
- * 0eeb032 - Changing default diff_formatter to unix (Beth, Thu Apr 24 08:19:15 2014 +1000)
12
- * ace5d4d - Update README.md (bethesque, Wed Apr 23 20:59:24 2014 +1000)
13
- * 24efef6 - Update configuration.md (bethesque, Wed Apr 23 20:51:00 2014 +1000)
14
- * 2d862b7 - Update best-practices.md (bethesque, Wed Apr 23 07:33:01 2014 +1000)
15
- * ff8dfd2 - Updated doco (Beth, Tue Apr 22 21:45:17 2014 +1000)
16
- * 88e4572 - Moving best practices into its own file (Beth, Tue Apr 22 21:28:36 2014 +1000)
17
- * 5a3b92c - Moving provider state documentation out of main README into it's own file. (Beth, Tue Apr 22 19:59:48 2014 +1000)
18
- * 1d568c4 - Updated configuration documentation (Beth, Tue Apr 22 13:06:47 2014 +1000)
19
- * be1412e - Added configuration documentation (Beth, Tue Apr 22 13:04:33 2014 +1000)
20
- * 9f9d178 - Added HAL raq (Beth, Tue Apr 22 12:51:42 2014 +1000)
21
- * d9b6479 - Renamed ListOfPathsFormatter to ListDiffFormatter (Beth, Tue Apr 22 12:48:57 2014 +1000)
22
- * 6b82402 - Renamed NestedJsonDiffFormatter to EmbeddedDiffFormatter (Beth, Tue Apr 22 12:45:50 2014 +1000)
23
- * def8afd - Merge branch 'master' into release-1.1.0 (bethesque, Tue Apr 22 09:13:41 2014 +1000)
24
- * 789a471 - Added generated docs to zoo-app (bethesque, Tue Apr 15 17:20:08 2014 +1000)
25
- * f5da7ab - Improved header match failure message (bethesque, Tue Apr 15 09:39:12 2014 +1000)
26
- * 1179489 - Stopped RSpec turning failure message lines that should be white to red (bethesque, Mon Apr 14 21:41:55 2014 +1000)
27
- * ddad510 - Added type and regexp matching output to ListOfPathsFormatter (bethesque, Mon Apr 14 13:43:08 2014 +1000)
28
- * b007248 - Added class based matching output to plus_and_minus diff formatter (bethesque, Sat Apr 12 21:20:43 2014 +1000)
29
- * f7910a1 - Swapped colored for term-ansicolor, as the colored mixins clash with other gems (bethesque, Sat Apr 12 20:37:57 2014 +1000)
30
- * 93bfbdb - Fixing failing tests caused by JRuby inserting a blank line between the braces of an empty hash. Moved ActiveSupportSupport into shared
31
- * da16f95 - Added after hook to allow customisation of Doc::Generator (bethesque, Sat Apr 12 18:46:04 2014 +1000)
32
- * 85a6fe3 - Breaking up configuration files into separate files (bethesque, Sat Apr 12 11:21:56 2014 +1000)
33
- * 7515360 - Merge branch 'doc' into release-1.1.0 (bethesque, Sat Apr 12 10:37:51 2014 +1000)
34
- * 1200481 - Removed pact_gem key from pact fixtures (bethesque, Wed Apr 9 22:19:02 2014 +1000)
35
- * 72d791b - Ordered rendering of keys in markdown (bethesque, Wed Apr 9 22:15:01 2014 +1000)
36
- * 000b223 - Hiding headers and body from docs when they are empty (bethesque, Wed Apr 9 21:46:02 2014 +1000)
37
- * 7f6ed91 - Changing request key ordering so it makes more sense when reading it (bethesque, Wed Apr 9 21:45:31 2014 +1000)
38
- * 65054a8 - Added index rendering (bethesque, Wed Apr 9 19:38:55 2014 +1000)
39
- * 9426565 - Refactoring generation code. Fixed rendering of interaction in markdown when ActiveSupport is loaded (bethesque, Wed Apr 9 18:20:53 2014 +100
40
- * 73d0dbf - WIP refactoring generator code (bethesque, Wed Apr 9 17:03:14 2014 +1000)
41
- * 7d1d07b - WIP tests and refactor doc generator (bethesque, Wed Apr 9 13:36:46 2014 +1000)
15
+ * 41fa409 - Cleaned up consumer after spec failure message (Beth, Sun Apr 27 22:18:03 2014 +1000)
16
+ * 8593fa9 - Updated zoo-app example (Beth, Sun Apr 27 20:54:51 2014 +1000)
17
+ * 716e3a8 - Added standalone consumer spec and spec for VerificationGet (Beth, Thu Apr 24 10:15:17 2014 +1000)
18
+ * c0f9bc6 - Copied RSpec::Expectations::Differ to Pact::Matchers::Differ - safer than trying to override behaviour (Beth, Thu Apr 24 09:17:58 2014 +
19
+ * 0eeb032 - Changing default diff_formatter to unix (Beth, Thu Apr 24 08:19:15 2014 +1000)
20
+ * ace5d4d - Update README.md (bethesque, Wed Apr 23 20:59:24 2014 +1000)
21
+ * 24efef6 - Update configuration.md (bethesque, Wed Apr 23 20:51:00 2014 +1000)
22
+ * 2d862b7 - Update best-practices.md (bethesque, Wed Apr 23 07:33:01 2014 +1000)
23
+ * ff8dfd2 - Updated doco (Beth, Tue Apr 22 21:45:17 2014 +1000)
24
+ * 88e4572 - Moving best practices into its own file (Beth, Tue Apr 22 21:28:36 2014 +1000)
25
+ * 5a3b92c - Moving provider state documentation out of main README into it's own file. (Beth, Tue Apr 22 19:59:48 2014 +1000)
26
+ * 1d568c4 - Updated configuration documentation (Beth, Tue Apr 22 13:06:47 2014 +1000)
27
+ * be1412e - Added configuration documentation (Beth, Tue Apr 22 13:04:33 2014 +1000)
28
+ * 9f9d178 - Added HAL raq (Beth, Tue Apr 22 12:51:42 2014 +1000)
29
+ * d9b6479 - Renamed ListOfPathsFormatter to ListDiffFormatter (Beth, Tue Apr 22 12:48:57 2014 +1000)
30
+ * 6b82402 - Renamed NestedJsonDiffFormatter to EmbeddedDiffFormatter (Beth, Tue Apr 22 12:45:50 2014 +1000)
31
+ * def8afd - Merge branch 'master' into release-1.1.0 (bethesque, Tue Apr 22 09:13:41 2014 +1000)
32
+ * 789a471 - Added generated docs to zoo-app (bethesque, Tue Apr 15 17:20:08 2014 +1000)
33
+ * f5da7ab - Improved header match failure message (bethesque, Tue Apr 15 09:39:12 2014 +1000)
34
+ * 1179489 - Stopped RSpec turning failure message lines that should be white to red (bethesque, Mon Apr 14 21:41:55 2014 +1000)
35
+ * ddad510 - Added type and regexp matching output to ListOfPathsFormatter (bethesque, Mon Apr 14 13:43:08 2014 +1000)
36
+ * b007248 - Added class based matching output to plus_and_minus diff formatter (bethesque, Sat Apr 12 21:20:43 2014 +1000)
37
+ * f7910a1 - Swapped colored for term-ansicolor, as the colored mixins clash with other gems (bethesque, Sat Apr 12 20:37:57 2014 +1000)
38
+ * 93bfbdb - Fixing failing tests caused by JRuby inserting a blank line between the braces of an empty hash. Moved ActiveSupportSupport into shared
39
+ * da16f95 - Added after hook to allow customisation of Doc::Generator (bethesque, Sat Apr 12 18:46:04 2014 +1000)
40
+ * 85a6fe3 - Breaking up configuration files into separate files (bethesque, Sat Apr 12 11:21:56 2014 +1000)
41
+ * 7515360 - Merge branch 'doc' into release-1.1.0 (bethesque, Sat Apr 12 10:37:51 2014 +1000)
42
+ * 1200481 - Removed pact_gem key from pact fixtures (bethesque, Wed Apr 9 22:19:02 2014 +1000)
43
+ * 72d791b - Ordered rendering of keys in markdown (bethesque, Wed Apr 9 22:15:01 2014 +1000)
44
+ * 000b223 - Hiding headers and body from docs when they are empty (bethesque, Wed Apr 9 21:46:02 2014 +1000)
45
+ * 7f6ed91 - Changing request key ordering so it makes more sense when reading it (bethesque, Wed Apr 9 21:45:31 2014 +1000)
46
+ * 65054a8 - Added index rendering (bethesque, Wed Apr 9 19:38:55 2014 +1000)
47
+ * 9426565 - Refactoring generation code. Fixed rendering of interaction in markdown when ActiveSupport is loaded (bethesque, Wed Apr 9 18:20:53 2014 +100
48
+ * 73d0dbf - WIP refactoring generator code (bethesque, Wed Apr 9 17:03:14 2014 +1000)
49
+ * 7d1d07b - WIP tests and refactor doc generator (bethesque, Wed Apr 9 13:36:46 2014 +1000)
42
50
 
43
51
  ### 1.0.39 (8 April 2014)
44
52
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact (1.1.0.rc3)
4
+ pact (1.1.0.rc4)
5
5
  awesome_print (~> 1.1)
6
6
  find_a_port (~> 1.0.1)
7
7
  json
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- pact (1.1.0.rc2)
4
+ pact (1.1.0.rc3)
5
5
  awesome_print (~> 1.1)
6
6
  find_a_port (~> 1.0.1)
7
7
  json
@@ -21,23 +21,28 @@ module Pact
21
21
  attr_accessor :log_dir
22
22
  attr_accessor :doc_dir
23
23
  attr_accessor :reports_dir
24
- attr_accessor :logger
24
+ attr_writer :logger
25
25
  attr_accessor :tmp_dir
26
26
  attr_writer :pactfile_write_mode
27
27
 
28
28
  attr_accessor :error_stream
29
29
  attr_accessor :output_stream
30
30
 
31
- def log_path
32
- log_dir + "/pact.log"
31
+ def self.default_configuration
32
+ c = Configuration.new
33
+ c.pact_dir = File.expand_path('./spec/pacts')
34
+ c.tmp_dir = File.expand_path('./tmp/pacts')
35
+ c.log_dir = default_log_dir
36
+ c.pactfile_write_mode = :overwrite
37
+ c.reports_dir = File.expand_path('./reports/pacts')
38
+ c.doc_dir = File.expand_path("./doc/pacts")
39
+ c.output_stream = $stdout
40
+ c.error_stream = $stderr
41
+ c
33
42
  end
34
43
 
35
- def pactfile_write_mode
36
- if @pactfile_write_mode == :smart
37
- is_rake_running? ? :overwrite : :update
38
- else
39
- @pactfile_write_mode
40
- end
44
+ def logger
45
+ @logger ||= create_logger
41
46
  end
42
47
 
43
48
  def doc_generator= doc_generator
@@ -72,16 +77,39 @@ module Pact
72
77
  end
73
78
  end
74
79
 
80
+ def log_path
81
+ log_dir + "/pact.log"
82
+ end
83
+
84
+ def pactfile_write_mode
85
+ if @pactfile_write_mode == :smart
86
+ is_rake_running? ? :overwrite : :update
87
+ else
88
+ @pactfile_write_mode
89
+ end
90
+ end
91
+
75
92
  private
76
93
 
94
+ def self.default_log_dir
95
+ File.expand_path("./log")
96
+ end
97
+
77
98
  #Would love a better way of determining this! It sure won't work on windows.
78
99
  def is_rake_running?
79
100
  `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0
80
101
  end
102
+
103
+ def create_logger
104
+ FileUtils::mkdir_p log_dir
105
+ logger = Logger.new(log_path)
106
+ logger.level = Logger::DEBUG
107
+ logger
108
+ end
81
109
  end
82
110
 
83
111
  def self.configuration
84
- @configuration ||= default_configuration
112
+ @configuration ||= Configuration.default_configuration
85
113
  end
86
114
 
87
115
  def self.configure
@@ -90,34 +118,7 @@ module Pact
90
118
  end
91
119
 
92
120
  def self.clear_configuration
93
- @configuration = default_configuration
94
- end
95
-
96
- private
97
-
98
- def self.default_configuration
99
- c = Configuration.new
100
- c.pact_dir = File.expand_path('./spec/pacts')
101
- c.tmp_dir = File.expand_path('./tmp/pacts')
102
- c.log_dir = default_log_dir
103
- c.logger = default_logger c.log_path
104
- c.pactfile_write_mode = :overwrite
105
- c.reports_dir = File.expand_path('./reports/pacts')
106
- c.doc_dir = File.expand_path("./doc")
107
- c.output_stream = $stdout
108
- c.error_stream = $stderr
109
- c
110
- end
111
-
112
- def self.default_log_dir
113
- File.expand_path("./log")
114
- end
115
-
116
- def self.default_logger path
117
- FileUtils::mkdir_p File.dirname(path)
118
- logger = Logger.new(path)
119
- logger.level = Logger::DEBUG
120
- logger
121
+ @configuration = nil
121
122
  end
122
123
 
123
124
  end
@@ -23,9 +23,9 @@ module Pact
23
23
  interaction = Interaction.from_hash(JSON.load(env['rack.input'].string))
24
24
  interaction_list.add interaction
25
25
  logger.info "Registered expected interaction #{interaction.request.method_and_path}"
26
- logger.debug JSON.pretty_generate interaction
26
+ logger.debug JSON.pretty_generate JSON.parse(interaction.to_json)
27
27
  [200, {}, ['Added interaction']]
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -29,8 +29,8 @@ module Pact
29
29
 
30
30
  def find_response request_hash
31
31
  actual_request = Request::Actual.from_hash(request_hash)
32
- logger.info "#{name} received request #{actual_request.method_and_path}"
33
- logger.debug JSON.pretty_generate actual_request
32
+ logger.info "Received request #{actual_request.method_and_path}"
33
+ logger.debug pretty_generate actual_request
34
34
  candidate_interactions = interaction_list.find_candidate_interactions actual_request
35
35
  matching_interactions = find_matching_interactions actual_request, from: candidate_interactions
36
36
 
@@ -52,8 +52,8 @@ module Pact
52
52
  def handle_matched_interaction interaction
53
53
  interaction_list.register_matched interaction
54
54
  response = response_from(interaction.response)
55
- logger.info "Found matching response on #{name}:"
56
- logger.ap interaction.response
55
+ logger.info "Found matching response for #{interaction.request.method_and_path}"
56
+ logger.debug pretty_generate(interaction.response)
57
57
  response
58
58
  end
59
59
 
@@ -66,8 +66,10 @@ module Pact
66
66
  end
67
67
 
68
68
  def handle_more_than_one_matching_interaction actual_request, matching_interactions
69
- logger.error "Multiple interactions found on #{name}:"
70
- logger.ap matching_interactions.collect(&:as_json)
69
+ logger.error "Multiple interactions found for #{actual_request.method_and_path}:"
70
+ matching_interactions.each do | interaction |
71
+ logger.debug pretty_generate(interaction)
72
+ end
71
73
  multiple_interactions_found_response actual_request, matching_interactions
72
74
  end
73
75
 
@@ -119,6 +121,11 @@ module Pact
119
121
  def logger_info_ap msg
120
122
  logger.info msg
121
123
  end
124
+
125
+ #Doesn't seem to reliably pretty generate unless we go to JSON and back again :(
126
+ def pretty_generate object
127
+ JSON.pretty_generate(JSON.parse(object.to_json))
128
+ end
122
129
  end
123
130
  end
124
- end
131
+ end
@@ -18,7 +18,7 @@ module Pact
18
18
  end
19
19
 
20
20
  def call
21
- ensure_target_dir_exists
21
+ ensure_target_dir_exists_and_is_clean
22
22
  write_index if consumer_contracts.any?
23
23
  write_doc_files
24
24
  perform_after_hook
@@ -68,7 +68,8 @@ module Pact
68
68
  after.call(pact_dir, target_dir, consumer_contracts)
69
69
  end
70
70
 
71
- def ensure_target_dir_exists
71
+ def ensure_target_dir_exists_and_is_clean
72
+ FileUtils.rm_rf target_dir
72
73
  FileUtils.mkdir_p target_dir
73
74
  end
74
75
 
@@ -66,7 +66,7 @@ module Pact
66
66
  attr_reader :interaction, :consumer_contract
67
67
 
68
68
  def clean_request
69
- ordered_clean_hash Reification.from_term(interaction.request).to_hash
69
+ ordered_clean_hash Reification.from_term(interaction.request)
70
70
  end
71
71
 
72
72
  def clean_response
@@ -17,6 +17,8 @@ module Pact
17
17
  mem << from_term(term)
18
18
  mem
19
19
  end
20
+ when term.is_a?(Pact::Request::Base)
21
+ from_term(term.to_hash)
20
22
  else
21
23
  term
22
24
  end
@@ -41,20 +41,11 @@ module Pact
41
41
  end
42
42
 
43
43
  def method_and_path
44
- "#{method.upcase} #{path}"
44
+ "#{method.upcase} #{display_path}"
45
45
  end
46
46
 
47
47
  def full_path
48
- fp = ''
49
- if path.empty?
50
- fp << "/"
51
- else
52
- fp << path
53
- end
54
- if query && !query.empty?
55
- fp << ("?" + (query.kind_of?(Pact::Term) ? query.generate : query))
56
- end
57
- fp
48
+ display_path + display_query
58
49
  end
59
50
 
60
51
  protected
@@ -67,6 +58,14 @@ module Pact
67
58
  keep_keys = [:method, :path, :headers, :query]
68
59
  as_json.reject{ |key, value| !keep_keys.include? key }
69
60
  end
61
+
62
+ def display_path
63
+ path.empty? ? "/" : path
64
+ end
65
+
66
+ def display_query
67
+ (query.nil? || query.empty?) ? '' : "?#{Pact::Reification.from_term(query)}"
68
+ end
70
69
  end
71
70
  end
72
71
  end
data/lib/pact/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pact
2
- VERSION = "1.1.0.rc3"
2
+ VERSION = "1.1.0.rc4"
3
3
  end
@@ -25,6 +25,37 @@ describe Pact do
25
25
  describe Pact::Configuration do
26
26
  let(:configuration) { Pact::Configuration.new }
27
27
 
28
+ describe "log_dir" do
29
+ it "sets the location of the logs" do
30
+ expect(Logger).to receive(:new).with("./tmp/logs/pact.log").and_call_original
31
+ Pact.configure do | config |
32
+ config.log_dir = "./tmp/logs"
33
+ end
34
+ Pact.configuration.logger
35
+ end
36
+ end
37
+
38
+ describe "logger" do
39
+ it "sets the location of the logs to log_dir by default" do
40
+ expect(Logger).to receive(:new).with(File.expand_path("./log/pact.log")).and_call_original
41
+ Pact.configuration.logger
42
+ end
43
+ it "defaults to DEBUG" do
44
+ expect(Pact.configuration.logger.level).to eq Logger::DEBUG
45
+ end
46
+ end
47
+
48
+ describe "doc_dir" do
49
+ it "defaults to ./doc/pacts" do
50
+ expect(Pact.configuration.doc_dir).to eq File.expand_path("./doc/pacts")
51
+ end
52
+
53
+ it "can be changed" do
54
+ Pact.configuration.doc_dir = "newdir"
55
+ expect(Pact.configuration.doc_dir).to eq "newdir"
56
+ end
57
+ end
58
+
28
59
  describe "doc_generator" do
29
60
 
30
61
  context "with a symbol" do
@@ -34,6 +34,22 @@ module Pact
34
34
 
35
35
  subject { Generator.new(pact_dir, doc_dir, options) }
36
36
 
37
+ context "when there are existing files" do
38
+ let(:existing_doc_file_path) { File.join(doc_dir, doc_type, "leftover") }
39
+
40
+ before do
41
+ FileUtils.mkdir_p File.dirname(existing_doc_file_path)
42
+ FileUtils.touch existing_doc_file_path
43
+ end
44
+
45
+ it "clears the existing files" do
46
+ expect(File.exist?(existing_doc_file_path)).to be_true
47
+ subject.call
48
+ expect(File.exist?(existing_doc_file_path)).to be_false
49
+ end
50
+ end
51
+
52
+
37
53
  it "creates an index" do
38
54
  expect(index_renderer).to receive(:call).with("Some Consumer", {"Some Provider"=>"Some Consumer - Some Provider.md"})
39
55
  subject.call
@@ -63,7 +79,6 @@ module Pact
63
79
 
64
80
  end
65
81
 
66
-
67
82
  end
68
83
  end
69
84
  end
@@ -64,6 +64,16 @@ module Pact
64
64
  expect(subject.request).to_not include("headers")
65
65
  end
66
66
  end
67
+
68
+ context "when a Pact::Term is present" do
69
+ let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/interaction_view_model_with_terms.json'}
70
+ let(:interaction) { consumer_contract.interactions.first }
71
+
72
+ it "uses the generated value" do
73
+ expect(subject.request).to_not include("Term")
74
+ expect(subject.request).to include("sunny")
75
+ end
76
+ end
67
77
  end
68
78
 
69
79
  describe "response" do
@@ -104,6 +114,16 @@ module Pact
104
114
  expect(subject.response).to_not include("headers")
105
115
  end
106
116
  end
117
+
118
+ context "when a Pact::Term is present" do
119
+ let(:consumer_contract) { Pact::ConsumerContract.from_uri './spec/support/interaction_view_model_with_terms.json'}
120
+ let(:interaction) { consumer_contract.interactions.first }
121
+
122
+ it "uses the generated value" do
123
+ expect(subject.response).to_not include("Term")
124
+ expect(subject.response).to include("rainy")
125
+ end
126
+ end
107
127
  end
108
128
 
109
129
 
@@ -39,5 +39,17 @@ module Pact
39
39
 
40
40
  end
41
41
 
42
+ context "when reifying a Request" do
43
+
44
+ let(:request){ Pact::Request::Expected.from_hash(method: 'get', path: '/', body: Pact::Term.new(generate: "sunny", matcher: /sun/))}
45
+
46
+ subject { Reification.from_term(request) }
47
+
48
+ it "turns it into a hash before reifying it" do
49
+ expect(subject[:body]).to eq("sunny")
50
+ end
51
+
52
+ end
53
+
42
54
  end
43
55
  end
@@ -23,6 +23,57 @@ module Pact
23
23
  end
24
24
  end
25
25
 
26
+ describe "#full_path" do
27
+
28
+ subject { TestRequest.new("get", "/something", {}, {some: "things"} , query).full_path }
29
+
30
+ context "with a query that is a Pact::Term" do
31
+ let(:query) { Pact::Term.new(generate: "some=things", matcher: /some/) }
32
+ it "reifies and appends the query" do
33
+ expect(subject).to eq("/something?some=things")
34
+ end
35
+ end
36
+
37
+ context "with a query that is a string" do
38
+ let(:query) { "some=things" }
39
+ it "appends the query" do
40
+ expect(subject).to eq("/something?some=things")
41
+ end
42
+ end
43
+
44
+ context "with an empty query" do
45
+ let(:query) { "" }
46
+ it "does include a query" do
47
+ expect(subject).to eq("/something")
48
+ end
49
+ end
50
+
51
+ context "with a nil query" do
52
+ let(:query) { nil }
53
+ it "does not include a query" do
54
+ expect(subject).to eq("/something")
55
+ end
56
+ end
57
+ end
58
+
59
+ describe "#method_and_path" do
60
+ context "with an empty path" do
61
+ subject { TestRequest.new("get", "", {}, {} , "").method_and_path }
62
+
63
+ it "includes a slash" do
64
+ expect(subject).to eq("GET /")
65
+ end
66
+ end
67
+
68
+ context "with a path" do
69
+ subject { TestRequest.new("get", "/something", {}, {} , "").method_and_path }
70
+
71
+ it "includes the path" do
72
+ expect(subject).to eq("GET /something")
73
+ end
74
+ end
75
+ end
76
+
26
77
  end
27
78
  end
28
79
  end
@@ -0,0 +1,50 @@
1
+ {
2
+ "provider": {
3
+ "name": "a provider"
4
+ },
5
+ "consumer": {
6
+ "name": "a consumer"
7
+ },
8
+ "interactions": [
9
+ {
10
+ "description": "an interaction with terms",
11
+ "request": {
12
+ "method": "post",
13
+ "path": "/path",
14
+ "query": "some=thing",
15
+ "headers": {
16
+ "key": "a header"
17
+ },
18
+ "body": {
19
+ "term": {
20
+ "json_class": "Pact::Term",
21
+ "data": {
22
+ "generate": "sunny",
23
+ "matcher": {
24
+ "json_class": "Regexp",
25
+ "o": 0,
26
+ "s": "sun"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ },
32
+ "response": {
33
+ "status": 200,
34
+ "body": {
35
+ "term": {
36
+ "json_class": "Pact::Term",
37
+ "data": {
38
+ "generate": "rainy",
39
+ "matcher": {
40
+ "json_class": "Regexp",
41
+ "o": 0,
42
+ "s": "rain"
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
49
+ ]
50
+ }
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.1.0.rc3
4
+ version: 1.1.0.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-04-28 00:00:00.000000000 Z
16
+ date: 2014-05-01 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: randexp
@@ -322,8 +322,8 @@ files:
322
322
  - example/zoo-app/Gemfile
323
323
  - example/zoo-app/Gemfile.lock
324
324
  - example/zoo-app/Rakefile
325
- - example/zoo-app/doc/markdown/README.md
326
- - example/zoo-app/doc/markdown/Zoo App - Animal Service.md
325
+ - example/zoo-app/doc/pacts/markdown/README.md
326
+ - example/zoo-app/doc/pacts/markdown/Zoo App - Animal Service.md
327
327
  - example/zoo-app/lib/zoo_app/animal_service_client.rb
328
328
  - example/zoo-app/lib/zoo_app/models/alligator.rb
329
329
  - example/zoo-app/spec/pacts/zoo_app-animal_service.json
@@ -518,6 +518,7 @@ files:
518
518
  - spec/support/generated_index.md
519
519
  - spec/support/generated_markdown.md
520
520
  - spec/support/interaction_view_model.json
521
+ - spec/support/interaction_view_model_with_terms.json
521
522
  - spec/support/markdown_pact.json
522
523
  - spec/support/missing_provider_states_output.txt
523
524
  - spec/support/pact_helper.rb
@@ -544,9 +545,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
544
545
  - - ! '>='
545
546
  - !ruby/object:Gem::Version
546
547
  version: '0'
547
- segments:
548
- - 0
549
- hash: -2322515558717640410
550
548
  required_rubygems_version: !ruby/object:Gem::Requirement
551
549
  none: false
552
550
  requirements:
@@ -638,6 +636,7 @@ test_files:
638
636
  - spec/support/generated_index.md
639
637
  - spec/support/generated_markdown.md
640
638
  - spec/support/interaction_view_model.json
639
+ - spec/support/interaction_view_model_with_terms.json
641
640
  - spec/support/markdown_pact.json
642
641
  - spec/support/missing_provider_states_output.txt
643
642
  - spec/support/pact_helper.rb