pact 1.3.3 → 1.4.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/CHANGELOG.md +16 -1
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +34 -13
  4. data/README.md +3 -2
  5. data/example/animal-service/lib/animal_service/api.rb +1 -0
  6. data/example/zoo-app/lib/zoo_app/animal_service_client.rb +0 -9
  7. data/example/zoo-app/lib/zoo_app/models/alligator.rb +2 -0
  8. data/lib/pact.rb +6 -5
  9. data/lib/pact/cli.rb +0 -26
  10. data/lib/pact/consumer/configuration.rb +0 -1
  11. data/lib/pact/consumer/configuration/configuration_extensions.rb +51 -0
  12. data/lib/pact/consumer/consumer_contract_builder.rb +1 -2
  13. data/lib/pact/consumer/interaction_builder.rb +2 -4
  14. data/lib/pact/doc/interaction_view_model.rb +9 -6
  15. data/lib/pact/doc/sort_interactions.rb +1 -1
  16. data/lib/pact/provider/rspec.rb +11 -9
  17. data/lib/pact/version.rb +1 -1
  18. data/pact.gemspec +5 -0
  19. data/spec/lib/pact/consumer/interaction_builder_spec.rb +4 -8
  20. data/spec/support/case-insensitive-response-header-matching.json +21 -0
  21. data/spec/support/case-insensitive-response-header-matching.rb +15 -0
  22. data/tasks/pact-test.rake +5 -0
  23. metadata +42 -122
  24. data/lib/pact/configuration.rb +0 -195
  25. data/lib/pact/consumer/app_manager.rb +0 -158
  26. data/lib/pact/consumer/interactions_filter.rb +0 -48
  27. data/lib/pact/consumer/mock_service.rb +0 -2
  28. data/lib/pact/consumer/mock_service/app.rb +0 -82
  29. data/lib/pact/consumer/mock_service/interaction_delete.rb +0 -33
  30. data/lib/pact/consumer/mock_service/interaction_list.rb +0 -76
  31. data/lib/pact/consumer/mock_service/interaction_mismatch.rb +0 -73
  32. data/lib/pact/consumer/mock_service/interaction_post.rb +0 -31
  33. data/lib/pact/consumer/mock_service/interaction_replay.rb +0 -139
  34. data/lib/pact/consumer/mock_service/log_get.rb +0 -28
  35. data/lib/pact/consumer/mock_service/missing_interactions_get.rb +0 -30
  36. data/lib/pact/consumer/mock_service/mock_service_administration_endpoint.rb +0 -31
  37. data/lib/pact/consumer/mock_service/pact_post.rb +0 -33
  38. data/lib/pact/consumer/mock_service/rack_request_helper.rb +0 -51
  39. data/lib/pact/consumer/mock_service/verification_get.rb +0 -68
  40. data/lib/pact/consumer/mock_service_client.rb +0 -65
  41. data/lib/pact/consumer/mock_service_interaction_expectation.rb +0 -37
  42. data/lib/pact/consumer/request.rb +0 -27
  43. data/lib/pact/consumer/server.rb +0 -90
  44. data/lib/pact/consumer_contract.rb +0 -1
  45. data/lib/pact/consumer_contract/consumer_contract.rb +0 -115
  46. data/lib/pact/consumer_contract/consumer_contract_writer.rb +0 -84
  47. data/lib/pact/consumer_contract/file_name.rb +0 -19
  48. data/lib/pact/consumer_contract/headers.rb +0 -51
  49. data/lib/pact/consumer_contract/interaction.rb +0 -67
  50. data/lib/pact/consumer_contract/pact_file.rb +0 -24
  51. data/lib/pact/consumer_contract/request.rb +0 -73
  52. data/lib/pact/consumer_contract/service_consumer.rb +0 -28
  53. data/lib/pact/consumer_contract/service_provider.rb +0 -28
  54. data/lib/pact/logging.rb +0 -14
  55. data/lib/pact/matchers.rb +0 -1
  56. data/lib/pact/matchers/actual_type.rb +0 -16
  57. data/lib/pact/matchers/base_difference.rb +0 -37
  58. data/lib/pact/matchers/differ.rb +0 -153
  59. data/lib/pact/matchers/difference.rb +0 -13
  60. data/lib/pact/matchers/difference_indicator.rb +0 -26
  61. data/lib/pact/matchers/embedded_diff_formatter.rb +0 -62
  62. data/lib/pact/matchers/expected_type.rb +0 -35
  63. data/lib/pact/matchers/index_not_found.rb +0 -15
  64. data/lib/pact/matchers/list_diff_formatter.rb +0 -101
  65. data/lib/pact/matchers/matchers.rb +0 -139
  66. data/lib/pact/matchers/no_diff_indicator.rb +0 -18
  67. data/lib/pact/matchers/regexp_difference.rb +0 -13
  68. data/lib/pact/matchers/type_difference.rb +0 -16
  69. data/lib/pact/matchers/unexpected_index.rb +0 -11
  70. data/lib/pact/matchers/unexpected_key.rb +0 -11
  71. data/lib/pact/matchers/unix_diff_formatter.rb +0 -114
  72. data/lib/pact/reification.rb +0 -28
  73. data/lib/pact/rspec.rb +0 -53
  74. data/lib/pact/shared/active_support_support.rb +0 -51
  75. data/lib/pact/shared/dsl.rb +0 -76
  76. data/lib/pact/shared/jruby_support.rb +0 -18
  77. data/lib/pact/shared/json_differ.rb +0 -15
  78. data/lib/pact/shared/key_not_found.rb +0 -15
  79. data/lib/pact/shared/null_expectation.rb +0 -31
  80. data/lib/pact/shared/request.rb +0 -80
  81. data/lib/pact/shared/text_differ.rb +0 -14
  82. data/lib/pact/something_like.rb +0 -49
  83. data/lib/pact/symbolize_keys.rb +0 -12
  84. data/lib/pact/term.rb +0 -85
  85. data/spec/lib/pact/consumer/request_spec.rb +0 -24
  86. data/spec/lib/pact/consumer_contract/active_support_support_spec.rb +0 -58
  87. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +0 -180
  88. data/spec/lib/pact/consumer_contract/headers_spec.rb +0 -107
  89. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -107
  90. data/spec/lib/pact/consumer_contract/request_spec.rb +0 -329
  91. data/spec/lib/pact/matchers/differ_spec.rb +0 -214
  92. data/spec/lib/pact/matchers/difference_spec.rb +0 -22
  93. data/spec/lib/pact/matchers/embedded_diff_formatter_spec.rb +0 -90
  94. data/spec/lib/pact/matchers/index_not_found_spec.rb +0 -21
  95. data/spec/lib/pact/matchers/list_diff_formatter_spec.rb +0 -114
  96. data/spec/lib/pact/matchers/matchers_spec.rb +0 -500
  97. data/spec/lib/pact/matchers/regexp_difference_spec.rb +0 -20
  98. data/spec/lib/pact/matchers/type_difference_spec.rb +0 -34
  99. data/spec/lib/pact/matchers/unexpected_index_spec.rb +0 -20
  100. data/spec/lib/pact/matchers/unexpected_key_spec.rb +0 -20
  101. data/spec/lib/pact/matchers/unix_diff_formatter_spec.rb +0 -216
  102. data/spec/lib/pact/reification_spec.rb +0 -67
  103. data/spec/lib/pact/shared/dsl_spec.rb +0 -86
  104. data/spec/lib/pact/shared/json_differ_spec.rb +0 -36
  105. data/spec/lib/pact/shared/key_not_found_spec.rb +0 -20
  106. data/spec/lib/pact/shared/request_spec.rb +0 -111
  107. data/spec/lib/pact/shared/text_differ_spec.rb +0 -54
  108. data/spec/lib/pact/something_like_spec.rb +0 -21
  109. data/spec/lib/pact/term_spec.rb +0 -89
  110. data/spec/support/dsl_spec_support.rb +0 -7
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 1.4.0.rc2 (12 October 2014)
6
+
7
+ * 61036fc - Updating pact-support version (bethesque, Sun Oct 12 14:39:36 2014 +1100)
8
+
9
+ ### 1.4.0.rc1 (12 October 2014)
10
+
11
+ * df3342f - Removing pact server command as it is now in pact-mock_service (bethesque, Sun Oct 12 12:39:56 2014 +1100)
12
+ * 12ccdb7 - Making gem source configurable (bethesque, Sun Oct 12 12:39:32 2014 +1100)
13
+ * 5b76516 - Removed files that are now in pact-support (bethesque, Sun Oct 12 11:40:57 2014 +1100)
14
+ * c4365c5 - Fix bug in calling of SomethingLike serialisation (André Allavena, Fri Oct 10 15:39:57 2014 +1000)
15
+ * 546b5c7 - JSON isn't auto-loaded; require it before use. (Daniel Heath, Wed Oct 8 13:31:24 2014 +1100)
16
+ * 7cac7e9 - Replaced response hash with Response class - say no to Hash Driven Development (bethesque, Fri Oct 3 17:22:38 2014 +1000)
17
+ * 36940d3 - Added test cases to show response headers are case insensitive (bethesque, Fri Oct 3 15:25:03 2014 +1000)
18
+ * f4422e2 - Fix typos in README (Mark Dalgleish, Mon Sep 29 17:12:17 2014 +1000)
19
+
5
20
  ### 1.3.3 (23 September 2014)
6
21
 
7
22
  * 9106aac - Fixed reification when using FactoryGirl. (bethesque, Tue Sep 23 08:23:51 2014 +1000)
@@ -35,7 +50,7 @@ Do this to generate your change history
35
50
 
36
51
  ### 1.2.1.rc2 (13 June 2014)
37
52
 
38
- * d805f35 - Ensuring the pact RSpec formatter works for both rspec 2 and rspec 3 (Beth, Fri Jun 13 16:27:01 2014 +1000)
53
+ * d805f35 - Ensuring the pact RSpec formatter works for both rspec 2 and rspec 3 (bethesque, Fri Jun 13 16:27:01 2014 +1000)
39
54
  * 1669d46 - Fix require for sample app to work without munging LOAD_PATH (Daniel Heath, Fri Jun 13 15:50:03 2014 +1000)
40
55
 
41
56
  ### 1.2.1.rc1 (13 June 2014)
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in pact.gemspec
4
4
  gemspec
5
+
6
+ if ENV['X_PACT_DEVELOPMENT']
7
+ gem "pact-support", path: '../pact-support'
8
+ gem "pact-mock_service", path: '../pact-mock_service'
9
+ end
data/Gemfile.lock CHANGED
@@ -1,10 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact (1.3.3)
4
+ pact (1.4.0.rc2)
5
5
  awesome_print (~> 1.1)
6
6
  find_a_port (~> 1.0.1)
7
7
  json
8
+ pact-mock_service (~> 0.0.1)
9
+ pact-support (~> 0.0.2)
8
10
  rack-test (~> 0.6.2)
9
11
  randexp (~> 0.1.7)
10
12
  rspec (>= 2.14)
@@ -37,6 +39,25 @@ GEM
37
39
  method_source (0.8.2)
38
40
  minitest (5.3.4)
39
41
  multipart-post (2.0.0)
42
+ pact-mock_service (0.0.1)
43
+ awesome_print (~> 1.1)
44
+ find_a_port (~> 1.0.1)
45
+ json
46
+ rack
47
+ rack-test (~> 0.6.2)
48
+ rspec (>= 2.14)
49
+ term-ansicolor (~> 1.0)
50
+ thor
51
+ webrick
52
+ pact-support (0.0.2)
53
+ awesome_print (~> 1.1)
54
+ find_a_port (~> 1.0.1)
55
+ json
56
+ rack-test (~> 0.6.2)
57
+ randexp (~> 0.1.7)
58
+ rspec (>= 2.14)
59
+ term-ansicolor (~> 1.0)
60
+ thor
40
61
  pry (0.10.0)
41
62
  coderay (~> 1.1.0)
42
63
  method_source (~> 0.8.1)
@@ -46,25 +67,25 @@ GEM
46
67
  rack (>= 1.0)
47
68
  rake (10.0.4)
48
69
  randexp (0.1.7)
49
- rspec (3.0.0)
50
- rspec-core (~> 3.0.0)
51
- rspec-expectations (~> 3.0.0)
52
- rspec-mocks (~> 3.0.0)
53
- rspec-core (3.0.4)
54
- rspec-support (~> 3.0.0)
55
- rspec-expectations (3.0.4)
70
+ rspec (3.1.0)
71
+ rspec-core (~> 3.1.0)
72
+ rspec-expectations (~> 3.1.0)
73
+ rspec-mocks (~> 3.1.0)
74
+ rspec-core (3.1.6)
75
+ rspec-support (~> 3.1.0)
76
+ rspec-expectations (3.1.2)
56
77
  diff-lcs (>= 1.2.0, < 2.0)
57
- rspec-support (~> 3.0.0)
58
- rspec-mocks (3.0.4)
59
- rspec-support (~> 3.0.0)
60
- rspec-support (3.0.4)
78
+ rspec-support (~> 3.1.0)
79
+ rspec-mocks (3.1.3)
80
+ rspec-support (~> 3.1.0)
81
+ rspec-support (3.1.2)
61
82
  safe_yaml (1.0.3)
62
83
  slop (3.5.0)
63
84
  term-ansicolor (1.3.0)
64
85
  tins (~> 1.0)
65
86
  thor (0.19.1)
66
87
  thread_safe (0.3.4)
67
- tins (1.3.2)
88
+ tins (1.3.3)
68
89
  tzinfo (1.2.1)
69
90
  thread_safe (~> 0.1)
70
91
  webmock (1.18.0)
data/README.md CHANGED
@@ -59,7 +59,7 @@ Put it in your Gemfile. You know how.
59
59
 
60
60
  ### Service Consumer project
61
61
 
62
- #### 1. Start with you model
62
+ #### 1. Start with your model
63
63
 
64
64
  Imagine a model class that looks something like this. The attributes for a Something live on a remote server, and will need to be retrieved by an HTTP call.
65
65
 
@@ -95,7 +95,7 @@ end
95
95
  ```
96
96
  #### 3. Configure the mock server
97
97
 
98
- The following code will create a mock service on localhost:1234 which will respond to your application's queries over HTTP as if it were the real "My Service Provider" app. It also creats a mock service provider object which you will use to set up your expectations. The method name to access the mock service provider will be what ever name you give as the service argument - in this case "my_service_provider"
98
+ The following code will create a mock service on localhost:1234 which will respond to your application's queries over HTTP as if it were the real "My Service Provider" app. It also creates a mock service provider object which you will use to set up your expectations. The method name to access the mock service provider will be what ever name you give as the service argument - in this case "my_service_provider"
99
99
 
100
100
 
101
101
  ```ruby
@@ -256,6 +256,7 @@ As in all things, there are good ways to implement Pacts, and there are not so g
256
256
  * [Provider States](https://github.com/realestate-com-au/pact/wiki/Provider-states)
257
257
  * [Verifying pacts](https://github.com/realestate-com-au/pact/wiki/Verifying-pacts)
258
258
  * [Sharing pacts between consumer and provider](https://github.com/realestate-com-au/pact/wiki/Sharing-pacts-between-consumer-and-provider)
259
+ * [Regular expressions and type matching with Pact](https://github.com/realestate-com-au/pact/wiki/Regular-expressions-and-type-matching-with-Pact)
259
260
  * [Frequently asked questions](https://github.com/realestate-com-au/pact/wiki/FAQ)
260
261
  * [Rarely asked questions](https://github.com/realestate-com-au/pact/wiki/RAQ)
261
262
  * [Best practices](https://github.com/realestate-com-au/pact/wiki/Best-practices)
@@ -1,5 +1,6 @@
1
1
  require 'sinatra/base'
2
2
  require_relative 'animal_repository'
3
+ require 'json'
3
4
 
4
5
  module AnimalService
5
6
 
@@ -7,15 +7,6 @@ module ZooApp
7
7
  include HTTParty
8
8
  base_uri 'animal-service.com'
9
9
 
10
- def self.find_alligators
11
- response = get("/alligators", :headers => {'Accept' => 'application/json'})
12
- handle_response response do
13
- parse_body(response).collect do | hash |
14
- ZooApp::Animals::Alligator.new(hash)
15
- end
16
- end
17
- end
18
-
19
10
  def self.find_alligator_by_name name
20
11
  response = get("/alligators/#{name}", :headers => {'Accept' => 'application/json'})
21
12
  when_successful(response) do
@@ -1,7 +1,9 @@
1
1
  module ZooApp
2
2
  module Animals
3
3
  class Alligator
4
+
4
5
  attr_reader :name
6
+
5
7
  def initialize attributes
6
8
  @name = attributes[:name]
7
9
  end
data/lib/pact.rb CHANGED
@@ -1,5 +1,6 @@
1
- require_relative 'pact/version'
2
- require_relative 'pact/configuration'
3
- require_relative 'pact/consumer'
4
- require_relative 'pact/provider'
5
- require_relative 'pact/consumer_contract'
1
+ require 'pact/support'
2
+ require 'pact/version'
3
+ require 'pact/configuration'
4
+ require 'pact/consumer'
5
+ require 'pact/provider'
6
+ require 'pact/consumer_contract'
data/lib/pact/cli.rb CHANGED
@@ -15,15 +15,6 @@ module Pact
15
15
  RunPactVerification.call(options)
16
16
  end
17
17
 
18
- desc 'service', "Start a mock service"
19
- method_option :port, aliases: "-p", desc: "Port on which to run the service"
20
- method_option :log, aliases: "-l", desc: "File to which to log output"
21
- method_option :quiet, aliases: "-q", desc: "If true, no admin messages will be shown"
22
-
23
- def service
24
- RunStandaloneMockService.call(options)
25
- end
26
-
27
18
  private
28
19
 
29
20
  def log message
@@ -98,23 +89,6 @@ module Pact
98
89
 
99
90
  end
100
91
 
101
- class RunStandaloneMockService
102
-
103
- def self.call options
104
- service_options = {}
105
- if options[:log]
106
- log = File.open(options[:log], 'w')
107
- log.sync = true
108
- service_options[:log_file] = log
109
- end
110
-
111
- port = options[:port] || FindAPort.available_port
112
- mock_service = Consumer::MockService.new(service_options)
113
- trap(:INT) { Rack::Handler::WEBrick.shutdown }
114
- Rack::Handler::WEBrick.run(mock_service, :Port => port, :AccessLog => [])
115
- end
116
- end
117
-
118
92
  class SpecCriteria
119
93
 
120
94
  def self.call
@@ -6,6 +6,5 @@ require 'pact/consumer/configuration/service_provider'
6
6
  require 'pact/consumer/configuration/dsl'
7
7
  require 'pact/consumer/configuration/configuration_extensions'
8
8
 
9
-
10
9
  Pact.send(:extend, Pact::Consumer::DSL)
11
10
  Pact::Configuration.send(:include, Pact::Consumer::Configuration::ConfigurationExtensions)
@@ -1,14 +1,65 @@
1
+ require 'pact/configuration'
2
+ require 'pact/doc/markdown/generator'
3
+
1
4
  module Pact
2
5
  module Consumer
3
6
  module Configuration
4
7
 
5
8
  module ConfigurationExtensions
9
+
10
+ DOC_GENERATORS = { markdown: Pact::Doc::Markdown::Generator }
11
+
12
+ def doc_dir
13
+ @doc_dir ||= File.expand_path("./doc/pacts")
14
+ end
15
+
16
+ def doc_dir= doc_dir
17
+ @doc_dir = doc_dir
18
+ end
19
+
6
20
  def add_provider_verification &block
7
21
  provider_verifications << block
8
22
  end
23
+
9
24
  def provider_verifications
10
25
  @provider_verifications ||= []
11
26
  end
27
+
28
+ def doc_generator= doc_generator
29
+ doc_generators << begin
30
+ if DOC_GENERATORS[doc_generator]
31
+ DOC_GENERATORS[doc_generator]
32
+ elsif doc_generator.respond_to?(:call)
33
+ doc_generator
34
+ else
35
+ raise "Pact.configuration.doc_generator needs to respond to call, or be in the preconfigured list: #{DOC_GENERATORS.keys}"
36
+ end
37
+ end
38
+ end
39
+
40
+ def doc_generators
41
+ @doc_generators ||= []
42
+ end
43
+
44
+ def pactfile_write_mode
45
+ @pactfile_write_mode ||= :overwrite
46
+ if @pactfile_write_mode == :smart
47
+ is_rake_running? ? :overwrite : :update
48
+ else
49
+ @pactfile_write_mode
50
+ end
51
+ end
52
+
53
+ def pactfile_write_mode= pactfile_write_mode
54
+ @pactfile_write_mode = pactfile_write_mode
55
+ end
56
+
57
+ private
58
+
59
+ #Would love a better way of determining this! It sure won't work on windows.
60
+ def is_rake_running?
61
+ `ps -ef | grep rake | grep #{Process.ppid} | grep -v 'grep'`.size > 0
62
+ end
12
63
  end
13
64
  end
14
65
  end
@@ -35,8 +35,7 @@ module Pact
35
35
  def interaction_builder
36
36
  @interaction_builder ||=
37
37
  begin
38
- interaction_builder = InteractionBuilder.new
39
- interaction_builder.on_interaction_fully_defined do | interaction |
38
+ interaction_builder = InteractionBuilder.new do | interaction |
40
39
  self.handle_interaction_fully_defined(interaction)
41
40
  end
42
41
  interaction_builder
@@ -8,8 +8,9 @@ module Pact
8
8
 
9
9
  attr_reader :interaction
10
10
 
11
- def initialize
11
+ def initialize &block
12
12
  @interaction = Interaction.new
13
+ @callback = block
13
14
  end
14
15
 
15
16
  def upon_receiving description
@@ -33,9 +34,6 @@ module Pact
33
34
  self
34
35
  end
35
36
 
36
- def on_interaction_fully_defined &block
37
- @callback = block
38
- end
39
37
  end
40
38
  end
41
39
  end
@@ -31,7 +31,7 @@ module Pact
31
31
  end
32
32
 
33
33
  def response_status
34
- interaction.response['status']
34
+ interaction.response.status
35
35
  end
36
36
 
37
37
  def consumer_name
@@ -67,7 +67,10 @@ module Pact
67
67
  attr_reader :interaction, :consumer_contract
68
68
 
69
69
  def clean_request
70
- ordered_clean_hash Reification.from_term(interaction.request)
70
+ reified_request = Reification.from_term(interaction.request)
71
+ ordered_clean_hash(reified_request).tap do | hash |
72
+ hash[:body] = reified_request[:body] if reified_request[:body]
73
+ end
71
74
  end
72
75
 
73
76
  def clean_response
@@ -80,17 +83,17 @@ module Pact
80
83
  def ordered_clean_hash source
81
84
  ordered_keys.each_with_object({}) do |key, target|
82
85
  if source.key? key
83
- target[key] = source[key] unless value_is_an_empty_hash_that_is_not_request_body(source[key], key)
86
+ target[key] = source[key] unless value_is_an_empty_hash(source[key])
84
87
  end
85
88
  end
86
89
  end
87
90
 
88
- def value_is_an_empty_hash_that_is_not_request_body value, key
89
- value.is_a?(Hash) && value.empty? && key != :body
91
+ def value_is_an_empty_hash value
92
+ value.is_a?(Hash) && value.empty?
90
93
  end
91
94
 
92
95
  def ordered_keys
93
- [:method, :path, :query, :headers, :body, "status", "headers","body"]
96
+ [:method, :path, :query, :status, :headers, :body]
94
97
  end
95
98
 
96
99
  def remove_key_if_empty key, hash
@@ -9,7 +9,7 @@ module Pact
9
9
  private
10
10
 
11
11
  def self.sortable_id interaction
12
- "#{interaction.description.downcase} #{interaction.response['status']} #{(interaction.provider_state || '').downcase}"
12
+ "#{interaction.description.downcase} #{interaction.response.status} #{(interaction.provider_state || '').downcase}"
13
13
  end
14
14
 
15
15
  end
@@ -68,8 +68,10 @@ module Pact
68
68
 
69
69
  describe description_for(interaction), metadata do
70
70
 
71
+
71
72
  describe "with #{interaction.request.method_and_path}" do
72
73
 
74
+
73
75
  interaction_context = InteractionContext.new
74
76
 
75
77
  before do | example |
@@ -87,7 +89,7 @@ module Pact
87
89
  end
88
90
  end
89
91
 
90
- describe_response Pact::Term.unpack_regexps(interaction.response), interaction_context
92
+ describe_response Pact::Response.new(Pact::Term.unpack_regexps(interaction.response)), interaction_context
91
93
 
92
94
  end
93
95
 
@@ -101,27 +103,27 @@ module Pact
101
103
 
102
104
  include Pact::RSpec::Matchers
103
105
 
104
- let(:expected_response_status) { expected_response['status'] }
105
- let(:expected_response_body) { expected_response['body'] }
106
+ let(:expected_response_status) { expected_response.status }
107
+ let(:expected_response_body) { expected_response.body }
106
108
  let(:response) { interaction_context.last_response }
107
109
  let(:response_status) { response.status }
108
110
  let(:response_body) { parse_body_from_response(response) }
109
111
  let(:differ) { Pact.configuration.body_differ_for_content_type diff_content_type }
110
112
  let(:diff_formatter) { Pact.configuration.diff_formatter_for_content_type diff_content_type }
111
- let(:expected_content_type) { Pact::Headers.new(expected_response['headers'] || {})['Content-Type'] }
113
+ let(:expected_content_type) { Pact::Headers.new(expected_response.headers || {})['Content-Type'] }
112
114
  let(:actual_content_type) { response.headers['Content-Type']}
113
115
  let(:diff_content_type) { String === expected_content_type ? expected_content_type : actual_content_type } # expected_content_type may be a Regexp
114
116
  let(:diff_options) { { with: differ, diff_formatter: diff_formatter } }
115
117
 
116
- if expected_response['status']
117
- it "has status code #{expected_response['status']}" do
118
+ if expected_response.status
119
+ it "has status code #{expected_response.status}" do
118
120
  expect(response_status).to eql expected_response_status
119
121
  end
120
122
  end
121
123
 
122
- if expected_response['headers']
124
+ if expected_response.headers
123
125
  describe "includes headers" do
124
- expected_response['headers'].each do |name, expected_header_value|
126
+ expected_response.headers.each do |name, expected_header_value|
125
127
  it "\"#{name}\" with value #{expected_header_value.inspect}" do
126
128
  header_value = response.headers[name]
127
129
  expect(header_value).to match_header(name, expected_header_value)
@@ -130,7 +132,7 @@ module Pact
130
132
  end
131
133
  end
132
134
 
133
- if expected_response['body']
135
+ if expected_response.body
134
136
  it "has a matching body" do
135
137
  expect(response_body).to match_term expected_response_body, diff_options
136
138
  end