pact 1.0.3 → 1.0.4

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,4 +1,7 @@
1
- ### 1.0.4 (unreleased)
1
+ ### 1.0.4 (6 September 2013)
2
+
3
+ * Added pact/tasks as an easy way to load the rake tasks and classes into the client project [Beth Skurrie]
4
+ * Removed unused rake_task.rb file [Beth Skurrie]
2
5
 
3
6
  ### 1.0.3 (5 September 2013)
4
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact (1.0.3)
4
+ pact (1.0.4)
5
5
  awesome_print (~> 1.1.0)
6
6
  find_a_port (~> 1.0.1)
7
7
  hashie (~> 2.0)
data/README.md CHANGED
@@ -117,9 +117,12 @@ end
117
117
 
118
118
  #### Configure your service provider rack app
119
119
 
120
- Create a `pact_helper.rb` in your service provider project. The file must be called pact_helper.rb so the verification tasks can find it, however there is some flexibility in where it can be stored. The recommended place is `specs/service_providers/pact_helper.rb`.
120
+ Create a `pact_helper.rb` in your service provider project. The file must be called pact_helper.rb so the built in verification tasks can find it, however there is some flexibility in where it can be stored. The recommended place is `specs/service_providers/pact_helper.rb`.
121
121
 
122
122
  ```ruby
123
+ require 'spec_helper'
124
+ require 'provider_states_for_my_consumer' #See next section on setting up provider states
125
+
123
126
  Pact.service_provider "My Provider" do
124
127
  app { MyApp.new }
125
128
  end
@@ -185,16 +188,14 @@ Here is an example pact:verify:head task, pointing the the pact file for "some_c
185
188
 
186
189
  ```ruby
187
190
  Pact::VerificationTask.new(:head) do | pact |
188
- pact.uri 'http://our_build_server/MY-CONSUMER-BUILD/latestSuccessful/artifact/Pacts/some_consumer-this_service provider.json',
189
- support_file: './spec/consumers/pact_helper'
191
+ pact.uri 'http://our_build_server/MY-CONSUMER-BUILD/latestSuccessful/artifact/Pacts/some_consumer-this_service provider.json'
190
192
  end
191
193
  ```
192
194
 
193
195
  ```ruby
194
196
  # Ideally we'd like to be able to create a production task like this, but firewalls are making this tricky right now.
195
197
  Pact::VerificationTask.new(:production) do | pact |
196
- pact.uri 'http://our_prod_server/pacts/some_consumer-this_service_provider.json',
197
- support_file: './spec/consumers/pact_helper'
198
+ pact.uri 'http://our_prod_server/pacts/some_consumer-this_service_provider.json'
198
199
  end
199
200
  ```
200
201
 
@@ -0,0 +1,2 @@
1
+ load File.expand_path('../tasks/pact.rake', File.dirname(__FILE__))
2
+ require 'pact/verification_task'
@@ -11,15 +11,20 @@ require_relative 'pact_task_helper'
11
11
  end
12
12
 
13
13
  The pact.uri may be a local file system path or a remote URL.
14
- The support_file should include code that makes your rack app available for the rack testing framework.
14
+
15
+ To run a pact:verify:xxx task you need to define a pact_helper.rb, ideally in spec/service_consumers.
16
+ It should contain your service_provider definition, and load any provider state definition files.
17
+ It should also load all your app's dependencies (eg by calling out to spec_helper)
18
+
15
19
  Eg.
16
20
 
21
+ require 'spec_helper'
22
+ require 'provider_states_for_my_consumer'
23
+
17
24
  Pact.service_provider "My Provider" do
18
25
  app { TestApp.new }
19
26
  end
20
27
 
21
- It should also load all your app's dependencies (eg by calling out to spec_helper)
22
-
23
28
  =end
24
29
 
25
30
 
@@ -1,3 +1,3 @@
1
1
  module Pact
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -1,16 +1,16 @@
1
1
  require 'pact'
2
2
  require 'pact/pact_task_helper'
3
3
 
4
- include PactTaskHelper
4
+
5
5
  namespace :pact do
6
6
 
7
+ include PactTaskHelper
8
+
7
9
  desc "Runs the specified pact file against the service provider"
8
- task :verify, :pact_uri, :support_file do | t, args |
9
- puts 'BLSH'
10
+ task :verify, :pact_uri do | t, args |
10
11
  require 'pact/provider/pact_spec_runner'
11
12
  puts "Using pact at uri #{args[:pact_uri]}"
12
- puts "Using support file #{args[:support_file]}"
13
- pact_spec_config = {uri: args[:pact_uri], support_file: args[:support_file]}
13
+ pact_spec_config = {uri: args[:pact_uri]}
14
14
  exit_status = Pact::Provider::PactSpecRunner.run([pact_spec_config])
15
15
  fail failure_message if exit_status != 0
16
16
  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.3
4
+ version: 1.0.4
5
5
  prerelease:
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: 2013-09-14 00:00:00.000000000 Z
16
+ date: 2013-09-15 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: randexp
@@ -299,9 +299,9 @@ files:
299
299
  - lib/pact/provider/provider_state.rb
300
300
  - lib/pact/provider/rspec.rb
301
301
  - lib/pact/provider/test_methods.rb
302
- - lib/pact/rake_task.rb
303
302
  - lib/pact/reification.rb
304
303
  - lib/pact/request.rb
304
+ - lib/pact/tasks.rb
305
305
  - lib/pact/term.rb
306
306
  - lib/pact/verification_task.rb
307
307
  - lib/pact/version.rb
@@ -1,64 +0,0 @@
1
- require 'rake/tasklib'
2
-
3
-
4
- module Pact
5
-
6
- ##
7
- # To enable `rake pact`, put something like this in your Rakefile:
8
- #
9
- # ```
10
- # require 'pact/rake_task'
11
- #
12
- # Pact::RakeTask.new do |pact|
13
- # pact.file 'spec/pacts/some-pact.json',
14
- # from_url: 'http://example.com/some-pact.json'
15
- # pact.file 'spec/pacts/other-pact.json',
16
- # from_url: 'http://example.com/other-pact.json'
17
- # end
18
- # ```
19
- class RakeTask < ::Rake::TaskLib
20
- attr_reader :connections
21
-
22
- def initialize(name = :pact)
23
- @connections = []
24
-
25
- yield self
26
-
27
- namespace name do
28
- desc "Update integration pacts from external sources"
29
- task :pull do
30
- connections.each do |conn|
31
- body = fetch conn[:url]
32
- File.open(conn[:file], 'w') {|f| f.write body }
33
- puts "Wrote #{conn[:url]} to #{conn[:file]}"
34
- end
35
- end
36
- end
37
- task name => "#{name}:pull" # default task for the namespace
38
- end
39
-
40
- def file(filename, options = {})
41
- url = options.fetch(:from_url)
42
- @connections << {file: filename, url: url}
43
- end
44
-
45
- private
46
- # written with plain Net::HTTP to avoid bringing in extra dependencies
47
- def fetch(url_string, redirection_limit = 5)
48
- raise 'Too many HTTP redirects' if redirection_limit == 0
49
- url = URI.parse(url_string)
50
- response = Net::HTTP.get_response(url)
51
- case response
52
- when Net::HTTPSuccess then
53
- response.body
54
- when Net::HTTPRedirection then
55
- location = response['Location']
56
- fetch(location, redirection_limit - 1)
57
- else
58
- response.value # raise the appropriate error
59
- end
60
- end
61
- end
62
-
63
-
64
- end