pact-provider-proxy 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2E2ZmE4NTgyMjYyMDMyZTA2ZGQ4YzFkYzMxYWY0MDBhMmI5ZGQxNQ==
4
+ MDMwOGVmYTEzYTYwZmU4NjgwYTAwYzUyOTgzYjI3OWMwNjFiMzQ2ZA==
5
5
  data.tar.gz: !binary |-
6
- MzEwOWRiYTc3ZWE3MDJiZTY1YTliNjdmNDVjYTc2NDQ0M2I1M2M3Zg==
6
+ YThjZjgwOWQ3YmU5MWI1ZDM3MmQ0NzQ3MjRkNTZkNzY1YTQ3MWQ0Ng==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzQ1MjUyYzFjZGIyODhlYTk4Nzk3NGE4MjYxMmYxMTcwOWE3MjJhMjYzMWIx
10
- MzZmOGI3Mzg4OGNmMWZmMThiNDY3ZmQ1MjUzZjhlZWM3MDkzYjkwZmQwYTg1
11
- OWYxMmQ4ZGU0M2M1ZDM3YzIyZDRkMDA5YjI0ZjdjN2U0ODE1ZDU=
9
+ NDg4ZDdjMzQwMDZlMzNkY2Q5NzkyYzhkMGU3NmY5ODI5YTdiMTI4NDdiNDJh
10
+ Mzc3NzIzZTgwMGQyZWQwNTJlNjg3YmIyYjA3ZTNhMThlOTRkMzA3YzhhMGY2
11
+ YzlmNmU3YzE1ODAzMzYyMzM4NzUxNDhhNTc2NjM1YTQxZGM0ZDk=
12
12
  data.tar.gz: !binary |-
13
- MmNjYTNjOGQ2NTE2NmE0MzAwMTdhY2ExMWYyNmYxNzM4MThlMzAwMmFiYmNj
14
- MmU3MGQyZDY4NTA1NTQ0MmU1NTZlMzk1NmU5MjNmYTJmY2NiM2VlZjI1MDI3
15
- OGE4NGUzZTlmMGE0ZTNjMzFkNzUwOGQ1YTAwZTFhZWVlN2NmMzg=
13
+ ZjU0YTM4NzdkNmEzMzc1YTMzOWU4N2Y3YWE4MjRhMDBkMWQ0NWExMGEzMDg0
14
+ YzBjZGViMzk3YTdlMmIwYzhiYmVmYjYyOTgzNGZiMDZhNDUzYzEyZTRiN2Ri
15
+ OWE4ZWVjYzdjMTk1NTVhYzdlOTliMmEwNzE0MmQwMDhmNjBjYmU=
data/CHANGELOG.md CHANGED
@@ -0,0 +1,5 @@
1
+ git log --pretty=format:' * %h - %s (%an, %ad)'
2
+
3
+ ### 1.0.0 (5 June 2014)
4
+
5
+ * b697616 - Updated pact-provider-proxy to work with pact 1.1.1 (bethesque, Thu Jun 5 18:38:10 2014 +1000)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pact::Proxy
1
+ # Pact::Provider::Proxy
2
2
 
3
3
  Allows pact verification against a running provider at a configurable base URL (normal pact verification is run against a code base using Rack::Test::Methods - no process is actually spawned).
4
4
 
@@ -8,7 +8,7 @@ This allows testing against providers where you have access to a running instanc
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'pact-proxy'
11
+ gem 'pact-provider-proxy'
12
12
 
13
13
  And then execute:
14
14
 
@@ -16,12 +16,12 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install pact-proxy
19
+ $ gem install pact-provider-proxy
20
20
 
21
21
  ## Usage
22
22
 
23
23
  Usually, you would configure and run pact:verify in the provider code base.
24
- If you are using a pact-proxy to run your pact verify task, it is probably because you don't have access to the code base of the provider project, or it is not a ruby project, so it may make sense to include this task in your consumer project.
24
+ If you are using pact-provider-proxy to run your pact verify task, it is probably because you don't have access to the code base of the provider project, or it is not a ruby project, so it may make sense to include this task in your consumer project.
25
25
 
26
26
  Specifying a pact_helper is optional, and is only required if you are using provider states.
27
27
 
@@ -38,7 +38,7 @@ Then run:
38
38
 
39
39
  $ rake pact:verify:monolith
40
40
 
41
- If you have access to your provider code base, and are able to spawn an instance locally, you could add some rake tasks to start and stop your server. (Please note, I have actually run this code, I just think it should work...)
41
+ If you have access to your provider code base, and are able to spawn an instance locally, you could add some rake tasks to start and stop your server. (Please note, I have not actually run this code, I just think it should work...)
42
42
 
43
43
  ```ruby
44
44
 
@@ -66,7 +66,7 @@ end
66
66
 
67
67
  ```
68
68
 
69
- If a ruby adapter to the underlying datastore cannot be used to set up provider states, shell scripts that invoke code in the native language might work. If you have access to the code base, another alternative could be to provide an endpoint on your app that sets up data inside itself, that is only mounted in test mode. eg 'http://localhost:8080/setUpProviderState?name=a%20thing%20exists' and 'http://localhost:8080/tearDownProviderState?name=a%20thing%20exists'
69
+ If a ruby adapter to the underlying datastore cannot be used to set up provider states, shell scripts that invoke code in the native language might work. If you have access to the code base, another alternative could be to provide an endpoint on your app that sets up data inside itself, that is only mounted in test mode. eg 'http://localhost:8080/set-up-provider-state?name=a%20thing%20exists' and 'http://localhost:8080/tear-down-provider-state?name=a%20thing%20exists'
70
70
 
71
71
  ## Contributing
72
72
 
@@ -0,0 +1,12 @@
1
+ require 'pact/provider/rspec'
2
+ require 'rack/reverse_proxy'
3
+
4
+ Pact.service_provider "Running Provider Application" do
5
+ app do
6
+ Rack::ReverseProxy.new do
7
+ reverse_proxy '/', ENV.fetch('PACT_PROVIDER_BASE_URL')
8
+ end
9
+ end
10
+ end
11
+
12
+ require ENV['PACT_PROJECT_PACT_HELPER'] if ENV.fetch('PACT_PROJECT_PACT_HELPER','') != ''
@@ -0,0 +1,37 @@
1
+ require 'pact/provider/pact_helper_locator'
2
+ require 'rake/file_utils'
3
+
4
+ module Pact
5
+ module Provider
6
+ module Proxy
7
+ module TaskHelper
8
+
9
+ extend self
10
+
11
+ def execute_pact_verify pact_uri = nil, pact_helper = nil
12
+ execute_cmd verify_command(pact_helper || Pact::Provider::PactHelperLocater.pact_helper_path, pact_uri)
13
+ end
14
+
15
+ def handle_verification_failure
16
+ exit_status = yield
17
+ abort if exit_status != 0
18
+ end
19
+
20
+ def verify_command pact_helper, pact_uri = nil
21
+ command_parts = []
22
+ command_parts << FileUtils::RUBY
23
+ command_parts << "-S pact verify"
24
+ command_parts << "-h" << (pact_helper.end_with?(".rb") ? pact_helper : pact_helper + ".rb")
25
+ (command_parts << "-p" << pact_uri) if pact_uri
26
+ command_parts.flatten.join(" ")
27
+ end
28
+
29
+ def execute_cmd command
30
+ system(command) ? 0 : 1
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -1,11 +1,8 @@
1
1
  require 'rake/tasklib'
2
- require 'pact/tasks/task_helper'
3
2
 
4
3
  module Pact
5
4
  class ProxyVerificationTask < ::Rake::TaskLib
6
5
 
7
- include Pact::TaskHelper
8
-
9
6
  attr_reader :pact_spec_configs
10
7
 
11
8
  def initialize(name)
@@ -18,7 +15,7 @@ module Pact
18
15
 
19
16
 
20
17
  def pact_url(uri, options = {})
21
- @pact_spec_configs << {uri: uri, pact_helper: options.fetch(:pact_helper, pact_helper_url)}
18
+ @pact_spec_configs << {uri: uri, pact_helper: options[:pact_helper]}
22
19
  end
23
20
 
24
21
  # For compatiblity with the normal VerificationTask, allow task.uri
@@ -28,28 +25,37 @@ module Pact
28
25
  @provider_base_url = url
29
26
  end
30
27
 
31
- def pact_helper_url
32
- File.expand_path('../../../pact_helper', __FILE__)
33
- end
34
-
35
28
  private
36
29
 
37
30
  attr_reader :name
38
31
 
32
+ def project_pact_helper_path
33
+ begin
34
+ Pact::Provider::PactHelperLocater.pact_helper_path
35
+ rescue
36
+ ''
37
+ end
38
+ end
39
+
39
40
  def rake_task
40
41
  namespace :pact do
41
- desc "Verify provider against the consumer pacts for #{name}"
42
- task "verify:#{name}", :description, :provider_state do |t, args|
42
+ desc "Verify running provider against the consumer pacts for #{name}"
43
+ task "verify:#{name}" do |t, args|
44
+
45
+ require 'pact/provider/proxy/task_helper'
43
46
 
44
- require 'pact/provider/pact_spec_runner'
45
- require 'pact/provider/proxy/configure_service_provider'
47
+ proxy_pact_helper = File.expand_path('../../proxy_pact_helper.rb', __FILE__)
46
48
 
47
- Pact::Proxy::ConfigureServiceProvider.call @provider_base_url
48
- options = {criteria: spec_criteria(args)}
49
+ exit_statuses = pact_spec_configs.collect do | config |
50
+ ENV['PACT_PROVIDER_BASE_URL'] = @provider_base_url
51
+ ENV['PACT_PROJECT_PACT_HELPER'] = config[:pact_helper] || project_pact_helper_path
52
+ Pact::Provider::Proxy::TaskHelper.execute_pact_verify config[:uri], proxy_pact_helper
53
+ end
49
54
 
50
- handle_verification_failure do
51
- Provider::PactSpecRunner.new(@pact_spec_configs, options).run
55
+ Pact::Provider::Proxy::TaskHelper.handle_verification_failure do
56
+ exit_statuses.count{ | status | status != 0 }
52
57
  end
58
+
53
59
  end
54
60
  end
55
61
  end
@@ -1,7 +1,7 @@
1
1
  module Pact
2
2
  module Provider
3
3
  module Proxy
4
- VERSION = "0.0.2"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Allows verification of a pact against a running provider}
13
13
  spec.homepage = ""
14
14
  spec.license = "MIT"
15
+ spec.homepage = "https://github.com/bethesque/pact-provider-proxy"
15
16
 
16
17
  spec.files = `git ls-files`.split($/)
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -19,7 +20,8 @@ Gem::Specification.new do |spec|
19
20
  spec.require_paths = ["lib"]
20
21
 
21
22
  spec.add_dependency "rack-reverse-proxy"
22
- spec.add_dependency "pact"
23
+ spec.add_dependency "pact", "~>1.1.1"
23
24
  spec.add_development_dependency "bundler", "~> 1.3"
24
25
  spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "pry"
25
27
  end
@@ -0,0 +1,7 @@
1
+ require 'pact/provider/rspec'
2
+
3
+ Pact.provider_states_for "a consumer" do
4
+ provider_state "some state" do
5
+ no_op
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'pact/provider/rspec'
2
+
3
+ Pact.provider_states_for "a consumer" do
4
+ provider_state "some state" do
5
+ no_op
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ {
2
+ "consumer" : { "name": "a consumer"},
3
+ "provider" : { "name": "a running provider"},
4
+ "interactions": [
5
+ {
6
+ "description": "a request for the index",
7
+ "provider_state": null,
8
+ "request" : {
9
+ "method" : "get", "path": "/"
10
+ },
11
+ "response": {
12
+ "status" : 200
13
+ }
14
+ }
15
+
16
+ ]
17
+ }
data/spec/tasks.rake CHANGED
@@ -1,7 +1,17 @@
1
1
  require 'pact/provider/proxy/tasks'
2
2
 
3
3
  Pact::ProxyVerificationTask.new :monolith do | task |
4
- task.pact_url './spec/support/pact.json', :pact_helper => './spec/support/pact_helper'
4
+ task.pact_url './spec/support/pact.json', :pact_helper => './spec/support/custom_pact_helper'
5
+ task.provider_base_url 'http://localhost:9292'
6
+ end
7
+
8
+ Pact::ProxyVerificationTask.new :monolith_dynamic_pact_helper do | task |
9
+ task.pact_url './spec/support/pact.json'
10
+ task.provider_base_url 'http://localhost:9292'
11
+ end
12
+
13
+ Pact::ProxyVerificationTask.new :monolith_no_pact_helper do | task |
14
+ task.pact_url './spec/support/pact-with-no-provider-states.json'
5
15
  task.provider_base_url 'http://localhost:9292'
6
16
  end
7
17
 
@@ -15,7 +25,21 @@ namespace :pact do
15
25
  end
16
26
  end
17
27
 
18
- task 'pact:verify:monolith' => 'pact:test:spawn_test_monolith'
28
+ task 'delete_pact_helper' do
29
+ FileUtils.rm_rf './spec/support/pact_helper.rb'
30
+ end
31
+
32
+ task 'create_pact_helper' do
33
+ FileUtils.cp './spec/fixtures/template_pact_helper.rb', './spec/support/pact_helper.rb'
34
+ end
35
+
36
+ task 'create_custom_pact_helper' do
37
+ FileUtils.cp './spec/fixtures/template_pact_helper.rb', './spec/support/custom_pact_helper.rb'
38
+ end
39
+
40
+ task 'pact:verify:monolith' => ['pact:test:spawn_test_monolith', 'create_custom_pact_helper']
41
+ task 'pact:verify:monolith_dynamic_pact_helper' => ['pact:test:spawn_test_monolith','create_pact_helper']
42
+ task 'pact:verify:monolith_no_pact_helper' => ['pact:test:spawn_test_monolith', 'delete_pact_helper']
19
43
 
20
- task :spec => ['pact:verify:monolith']
44
+ task :spec => ['pact:verify:monolith_no_pact_helper','pact:verify:monolith','pact:verify:monolith_dynamic_pact_helper']
21
45
  task :default => [:spec]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-provider-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-reverse-proxy
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: pact
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.1.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.1.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: See summary
70
84
  email:
71
85
  - beth@bethesque.com
@@ -80,16 +94,19 @@ files:
80
94
  - README.md
81
95
  - Rakefile
82
96
  - lib/pact/provider/proxy.rb
83
- - lib/pact/provider/proxy/configure_service_provider.rb
84
- - lib/pact/provider/proxy/pact_helper.rb
97
+ - lib/pact/provider/proxy/proxy_pact_helper.rb
98
+ - lib/pact/provider/proxy/task_helper.rb
85
99
  - lib/pact/provider/proxy/tasks.rb
86
100
  - lib/pact/provider/proxy/tasks/proxy_verification_task.rb
87
101
  - lib/pact/provider/proxy/version.rb
88
102
  - pact-provider-proxy.gemspec
103
+ - spec/fixtures/template_pact_helper.rb
104
+ - spec/support/custom_pact_helper.rb
105
+ - spec/support/pact-with-no-provider-states.json
89
106
  - spec/support/pact.json
90
107
  - spec/support/pact_helper.rb
91
108
  - spec/tasks.rake
92
- homepage: ''
109
+ homepage: https://github.com/bethesque/pact-provider-proxy
93
110
  licenses:
94
111
  - MIT
95
112
  metadata: {}
@@ -114,6 +131,9 @@ signing_key:
114
131
  specification_version: 4
115
132
  summary: Allows verification of a pact against a running provider
116
133
  test_files:
134
+ - spec/fixtures/template_pact_helper.rb
135
+ - spec/support/custom_pact_helper.rb
136
+ - spec/support/pact-with-no-provider-states.json
117
137
  - spec/support/pact.json
118
138
  - spec/support/pact_helper.rb
119
139
  - spec/tasks.rake
@@ -1,22 +0,0 @@
1
- require 'pact/provider/rspec'
2
- require 'rack/reverse_proxy'
3
-
4
- module Pact
5
- module Proxy
6
-
7
- class ConfigureServiceProvider
8
-
9
- def self.call provider_base_url
10
-
11
- Pact.service_provider "Running Provider Application" do
12
- app do
13
- Rack::ReverseProxy.new do
14
- reverse_proxy '/', provider_base_url
15
- end
16
- end
17
- end
18
-
19
- end
20
- end
21
- end
22
- end
@@ -1 +0,0 @@
1
- # No op