diff --git a/Gemfile b/Gemfile index ccbbc00..224e611 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,9 @@ source 'https://rubygems.org' # Specify your gem's dependencies in pact.gemspec gemspec - +# if ENV['X_PACT_DEVELOPMENT'] +# gem "pact-ffi", path: '../pact-ruby-ffi' +# end group :test do gem 'faraday', '~> 2.0' gem 'faraday-retry', '~> 2.0' diff --git a/lib/pact/array_like.rb b/lib/pact/array_like.rb index 13bb30c..bd8176b 100644 --- a/lib/pact/array_like.rb +++ b/lib/pact/array_like.rb @@ -15,6 +15,8 @@ def to_hash { :json_class => self.class.name, :contents => contents, + 'pact:matcher:type' => 'type', + :value => [contents], :min => min } end diff --git a/lib/pact/configuration.rb b/lib/pact/configuration.rb index 8793222..025e9d3 100644 --- a/lib/pact/configuration.rb +++ b/lib/pact/configuration.rb @@ -6,7 +6,7 @@ require 'pact/shared/text_differ' require 'pact/shared/form_differ' require 'pact/shared/multipart_form_differ' - +# require 'pact/ffi/logger' module Pact @@ -45,6 +45,7 @@ def self.=~ other attr_accessor :pact_dir attr_accessor :log_dir attr_accessor :tmp_dir + # attr_accessor :rust_log_level attr_writer :logger @@ -58,7 +59,7 @@ def self.default_configuration c.pact_dir = File.expand_path('./spec/pacts') c.tmp_dir = File.expand_path('./tmp/pacts') c.log_dir = default_log_dir - + # c.rust_log_level = 0 c.output_stream = $stdout c.error_stream = $stderr c.pactfile_write_order = :chronological @@ -167,6 +168,7 @@ def is_rake_running? end def create_logger + # PactFfi::Logger.log_to_stdout(rust_log_level) FileUtils::mkdir_p log_dir logger = ::Logger.new(log_path) logger.level = ::Logger::DEBUG diff --git a/lib/pact/consumer_contract/http_consumer_contract_parser.rb b/lib/pact/consumer_contract/http_consumer_contract_parser.rb index e072bf5..af12fd5 100644 --- a/lib/pact/consumer_contract/http_consumer_contract_parser.rb +++ b/lib/pact/consumer_contract/http_consumer_contract_parser.rb @@ -26,7 +26,9 @@ def pact_specification_version hash # metadata.pactSpecificationVersion maybe_pact_specification_version_1 = hash[:metadata] && hash[:metadata]['pactSpecification'] && hash[:metadata]['pactSpecification']['version'] maybe_pact_specification_version_2 = hash[:metadata] && hash[:metadata]['pactSpecificationVersion'] - pact_specification_version = maybe_pact_specification_version_1 || maybe_pact_specification_version_2 + maybe_pact_specification_version_3 = hash[:metadata] && hash[:metadata]['pactSpecificationVersion'] + maybe_pact_specification_version_4 = hash[:metadata] && hash[:metadata]['pactSpecificationVersion'] + pact_specification_version = maybe_pact_specification_version_1 || maybe_pact_specification_version_2 || maybe_pact_specification_version_3 || maybe_pact_specification_version_4 pact_specification_version ? Pact::SpecificationVersion.new(pact_specification_version) : Pact::SpecificationVersion::NIL_VERSION end diff --git a/lib/pact/something_like.rb b/lib/pact/something_like.rb index 399a688..0f23ecb 100644 --- a/lib/pact/something_like.rb +++ b/lib/pact/something_like.rb @@ -15,8 +15,12 @@ def initialize contents def to_hash { + # pact ruby :json_class => self.class.name, - :contents => contents + :contents => contents, + # pact rust + 'pact:matcher:type' => 'type', + 'value' => contents } end diff --git a/lib/pact/term.rb b/lib/pact/term.rb index 0b27ca6..1b7905b 100644 --- a/lib/pact/term.rb +++ b/lib/pact/term.rb @@ -33,7 +33,12 @@ def initialize(attributes = {}) end def to_hash - { json_class: self.class.name, data: { generate: generate, matcher: fix_regexp(matcher) } } + # Pact-Ruby V2 Standard + # { json_class: self.class.name, data: { generate: generate, matcher: fix_regexp(matcher) } } + # Pact-Rust V2 Standard. + { "pact:matcher:type": 'regex', value: generate, regex: fix_regexp(matcher)['s'] } + # Both + { "pact:matcher:type": 'regex', value: generate, regex: fix_regexp(matcher)['s'], json_class: self.class.name, data: { generate: generate, matcher: fix_regexp(matcher) } } end def as_json(options = {}) diff --git a/pact-support.gemspec b/pact-support.gemspec index a984465..bbaaf84 100644 --- a/pact-support.gemspec +++ b/pact-support.gemspec @@ -23,6 +23,7 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "awesome_print", "~> 1.9" spec.add_runtime_dependency "diff-lcs", "~> 1.5" spec.add_runtime_dependency "expgen", "~> 0.1" + # spec.add_runtime_dependency 'pact-ffi', '~> 0.4' spec.add_development_dependency "rspec", ">= 2.14", "< 4.0" spec.add_development_dependency "rake", "~> 13.0"