Module: WireMockMapper

Defined in:
lib/configuration.rb,
lib/wiremock_mapper.rb,
lib/builders/helpers.rb,
lib/builders/match_builder.rb,
lib/builders/request_builder.rb,
lib/builders/response_builder.rb,
lib/builders/scenario_builder.rb,
lib/builders/url_match_builder.rb

Defined Under Namespace

Modules: Builders Classes: Configuration

Class Method Summary collapse

Class Method Details

.clear_mappings(url = Configuration.wiremock_url) ⇒ Object


29
30
31
# File 'lib/wiremock_mapper.rb', line 29

def clear_mappings(url = Configuration.wiremock_url)
  clear_wiremock_mappings(url)
end

.create_mapping(url = Configuration.wiremock_url, &block) ⇒ Object


6
7
8
# File 'lib/wiremock_mapper.rb', line 6

def create_mapping(url = Configuration.wiremock_url, &block)
  create_mapping_with_priority(nil, url, &block)
end

.create_mapping_with_priority(priority = nil, url = Configuration.wiremock_url) {|request_builder, response_builder, scenario_builder| ... } ⇒ Object

Yields:

  • (request_builder, response_builder, scenario_builder)

10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wiremock_mapper.rb', line 10

def create_mapping_with_priority(priority = nil, url = Configuration.wiremock_url)
  request_builder = deep_clone(Configuration.request_builder)
  response_builder = deep_clone(Configuration.response_builder)
  scenario_builder = deep_clone(Configuration.scenario_builder)

  yield request_builder, response_builder, scenario_builder

  body = { request: request_builder, response: response_builder }.merge(scenario_builder)
  body[:priority] = priority if priority

  response = send_to_wiremock(url, body)

  JSON.parse(response.body).fetch('id')
end

.delete_mapping(mapping_id, url = Configuration.wiremock_url) ⇒ Object


25
26
27
# File 'lib/wiremock_mapper.rb', line 25

def delete_mapping(mapping_id, url = Configuration.wiremock_url)
  delete_from_wiremock(url, mapping_id)
end

.reset_scenarios(url = Configuration.wiremock_url) ⇒ Object


33
34
35
# File 'lib/wiremock_mapper.rb', line 33

def reset_scenarios(url = Configuration.wiremock_url)
  reset_wiremock_scenarios(url)
end