Class: Pact::V2::Consumer::PactConfig::Http
- Defined in:
- lib/pact/v2/consumer/pact_config/http.rb
Instance Attribute Summary collapse
-
#mock_host ⇒ Object
readonly
Returns the value of attribute mock_host.
-
#mock_port ⇒ Object
readonly
Returns the value of attribute mock_port.
-
#pact_handle ⇒ Object
readonly
Returns the value of attribute pact_handle.
Attributes inherited from Base
#consumer_name, #log_level, #pact_dir, #provider_name
Instance Method Summary collapse
- #get_pact_specification(opts) ⇒ Object
- #init_pact ⇒ Object
-
#initialize(consumer_name:, provider_name:, opts: {}) ⇒ Http
constructor
A new instance of Http.
- #new_interaction(description = nil) ⇒ Object
- #reset_pact ⇒ Object
Constructor Details
#initialize(consumer_name:, provider_name:, opts: {}) ⇒ Http
Returns a new instance of Http.
12 13 14 15 16 17 18 19 20 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 12 def initialize(consumer_name:, provider_name:, opts: {}) super @mock_host = opts[:mock_host] || "127.0.0.1" @mock_port = opts[:mock_port] || 0 @log_level = opts[:log_level] || :info @pact_specification = get_pact_specification(opts) @pact_handle = init_pact end |
Instance Attribute Details
#mock_host ⇒ Object (readonly)
Returns the value of attribute mock_host.
10 11 12 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 10 def mock_host @mock_host end |
#mock_port ⇒ Object (readonly)
Returns the value of attribute mock_port.
10 11 12 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 10 def mock_port @mock_port end |
#pact_handle ⇒ Object (readonly)
Returns the value of attribute pact_handle.
10 11 12 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 10 def pact_handle @pact_handle end |
Instance Method Details
#get_pact_specification(opts) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 30 def get_pact_specification(opts) pact_spec_version = opts[:pact_specification] || "V4" unless pact_spec_version.match?(/^v?[1-4](\.\d+){0,2}$/i) raise ArgumentError, "Invalid pact specification version format \n Valid versions are 1, 1.1, 2, 3, 4. Default is V4 \n V prefix is optional, and case insensitive" end pact_spec_version = pact_spec_version.upcase pact_spec_version = "V#{pact_spec_version}" unless pact_spec_version.start_with?("V") pact_spec_version = pact_spec_version.sub(/(\.0+)+$/, "") pact_spec_version = pact_spec_version.tr(".", "_") PactFfi::FfiSpecificationVersion["SPECIFICATION_VERSION_#{pact_spec_version.upcase}"] end |
#init_pact ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 42 def init_pact handle = PactFfi.new_pact(consumer_name, provider_name) PactFfi.with_specification(handle, @pact_specification) PactFfi.(handle, "pact-ruby-v2", "pact-ffi", PactFfi.version) Pact::V2::Native::Logger.log_to_stdout(@log_level) handle end |
#new_interaction(description = nil) ⇒ Object
22 23 24 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 22 def new_interaction(description = nil) HttpInteractionBuilder.new(self, description: description) end |
#reset_pact ⇒ Object
26 27 28 |
# File 'lib/pact/v2/consumer/pact_config/http.rb', line 26 def reset_pact @pact_handle = init_pact end |