-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow different consumer contract parsers to be registered
- Loading branch information
Showing
10 changed files
with
39 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
lib/pact/consumer_contract/http_consumer_contract_parser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Pact | ||
class HttpConsumerContractParser | ||
include SymbolizeKeys | ||
|
||
def call(hash) | ||
hash = symbolize_keys(hash) | ||
interactions = if hash[:interactions] | ||
hash[:interactions].collect { |hash| Interaction.from_hash(hash)} | ||
elsif hash[:messages] | ||
hash[:messages].collect { |hash| Message.from_hash(hash)} | ||
else | ||
[] # or raise an error? | ||
end | ||
|
||
ConsumerContract.new( | ||
:consumer => ServiceConsumer.from_hash(hash[:consumer]), | ||
:provider => ServiceProvider.from_hash(hash[:provider]), | ||
:interactions => interactions | ||
) | ||
end | ||
|
||
def can_parse?(hash) | ||
hash.key?('interactions') || hash.key?(:interactions) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
spec/lib/pact/consumer_contract/message_spec_with_message_class.rb
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
spec/lib/pact/consumer_contract/message_spec_with_message_module.rb
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.