pact-messages 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/pact/messages.rb +8 -5
- data/lib/pact/messages/{contract_repository.rb → message_finder.rb} +20 -10
- data/lib/pact/messages/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bf23016fb5b118e634cf6cdc6d1f0b5fd3cf982
|
4
|
+
data.tar.gz: 2659b2fb82b529e729d137c2e1b8d7ee33f6b45c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d86e6c13fa8ac513a7486e076a3949e6c8affa0199621560391335ed6f3aa2f7ddce06359e8062208387b9664eaf4487d59a97652e48dfe95601e23d87ae4e
|
7
|
+
data.tar.gz: 13a1d65d19db1f3e7bbb35c30c9da3a89a1511629ab97ee9aa89dd0b949cc00f5ca6fbcf40706f1a4af7c0f21d80f530fd7704fc076e5558d05a12e0563f2882
|
data/README.md
CHANGED
@@ -62,6 +62,12 @@ Pact::Messages.service_consumer 'Message Consumer' do
|
|
62
62
|
end
|
63
63
|
```
|
64
64
|
|
65
|
+
To modify the default pact broker url (http://pact-broker) please set `Pact::Messages.pact_broker_url`:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
Pact::Messages.pact_broker_url = 'http://my-pact-broker'
|
69
|
+
```
|
70
|
+
|
65
71
|
|
66
72
|
### Define Mock Service
|
67
73
|
|
data/lib/pact/messages.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'pact'
|
2
|
+
require 'pact/messages/consumer'
|
3
|
+
require 'pact/messages/message_finder'
|
2
4
|
|
3
5
|
module Pact
|
4
6
|
module Messages
|
@@ -13,14 +15,15 @@ module Pact
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def get_message_contract(provider_name, consumer_name, provider_state = nil)
|
16
|
-
Pact::Messages::
|
18
|
+
Pact::Messages::MessageFinder.get_message_contract(provider_name, consumer_name, provider_state)
|
17
19
|
end
|
18
20
|
|
19
21
|
def get_message_sample(provider_name, consumer_name, provider_state = nil)
|
20
|
-
Pact::Messages::
|
22
|
+
Pact::Messages::MessageFinder.get_message_sample(provider_name, consumer_name, provider_state)
|
23
|
+
end
|
24
|
+
|
25
|
+
def pact_broker_url=(url)
|
26
|
+
Pact::Messages::MessageFinder.pact_broker_url = url
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
24
|
-
|
25
|
-
require 'pact/messages/consumer'
|
26
|
-
require 'pact/messages/contract_repository'
|
@@ -4,31 +4,41 @@ require 'pact'
|
|
4
4
|
|
5
5
|
module Pact
|
6
6
|
module Messages
|
7
|
-
module
|
7
|
+
module MessageFinder
|
8
|
+
@@pact_broker_url = 'http://pact-broker'
|
9
|
+
|
8
10
|
module_function
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
+
def pact_broker_url
|
13
|
+
@@pact_broker_url
|
14
|
+
end
|
15
|
+
|
16
|
+
def pact_broker_url=(url)
|
17
|
+
@@pact_broker_url = url
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_message_contract(provider_name, consumer_name, provider_state = nil, contract_uri = nil)
|
21
|
+
contract = get_contract(provider_name, consumer_name, contract_uri)
|
12
22
|
fail "Contract between #{provider_name} and #{consumer_name} not found" unless contract
|
13
23
|
find_response_for_provider_state(contract.interactions, provider_state)
|
14
24
|
end
|
15
25
|
|
16
|
-
def get_message_sample(provider_name, consumer_name, provider_state = nil)
|
17
|
-
Pact::Reification.from_term(get_message_contract(provider_name, consumer_name, provider_state))
|
26
|
+
def get_message_sample(provider_name, consumer_name, provider_state = nil, contract_uri = nil)
|
27
|
+
Pact::Reification.from_term(get_message_contract(provider_name, consumer_name, provider_state, contract_uri))
|
18
28
|
end
|
19
29
|
|
20
30
|
class << self
|
21
31
|
private
|
22
32
|
|
23
|
-
def get_contract(provider_name, consumer_name)
|
33
|
+
def get_contract(provider_name, consumer_name, contract_uri = nil)
|
24
34
|
# search for it locally, if not found look on the pack broker
|
25
35
|
Pact::Messages.consumer_world.find_contract(provider_name, consumer_name) ||
|
26
|
-
Pact::ConsumerContract.from_uri(
|
36
|
+
Pact::ConsumerContract.from_uri(contract_uri || pact_contract_uri(provider_name, consumer_name))
|
27
37
|
end
|
28
38
|
|
29
|
-
def
|
30
|
-
|
31
|
-
URI(
|
39
|
+
def pact_contract_uri(provider, consumer)
|
40
|
+
path = URI.encode("pacts/provider/#{provider}/consumer/#{consumer}/latest")
|
41
|
+
URI("#{pact_broker_url}/#{path}")
|
32
42
|
end
|
33
43
|
|
34
44
|
def find_response_for_provider_state(interactions, state)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-messages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Malkov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pact
|
@@ -136,7 +136,7 @@ files:
|
|
136
136
|
- lib/pact/messages/consumer/interaction_builder.rb
|
137
137
|
- lib/pact/messages/consumer/mock_service_factory.rb
|
138
138
|
- lib/pact/messages/consumer/world.rb
|
139
|
-
- lib/pact/messages/
|
139
|
+
- lib/pact/messages/message_finder.rb
|
140
140
|
- lib/pact/messages/version.rb
|
141
141
|
- pact-messages.gemspec
|
142
142
|
homepage: https://github.com/reevoo/pact-messages
|
@@ -159,10 +159,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
161
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.2.3
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Enables consumer driven contract testing for asynchronous message driven
|
166
166
|
systems.
|
167
167
|
test_files: []
|
168
|
-
has_rdoc:
|