Sha256: e748ad3bf785c842abdefbc1336f76600c9d1318c58eb4d6eb8626ea5a71dec1

Contents?: true

Size: 1.14 KB

Versions: 79

Compression:

Stored size: 1.14 KB

Contents

class HalRelationProxyApp

  # This hash allows us to do a dodgy "generators" implementation
  # It means we can use placeholder URLS for the relations in our consumer tests so that
  # the consumer does not need to know the actual URLs.
  PATH_REPLACEMENTS = {
    '/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-Condor-production' =>
      '/pacticipants/Condor/latest-version/production',
    '/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-Condor' =>
      '/pacticipants/Condor/latest-version',
    '/HAL-REL-PLACEHOLDER-PB-WEBHOOKS' =>
      '/webhooks'
  }

  RESPONSE_BODY_REPLACEMENTS = {
  }

  def initialize(app)
    @app = app
  end

  def call env
    env_with_modified_path = env
    PATH_REPLACEMENTS.each do | (find, replace) |
      env_with_modified_path['PATH_INFO'] = env_with_modified_path['PATH_INFO'].gsub(find, replace)
    end

    response = @app.call(env_with_modified_path)

    modified_response_body = response.last.join
    RESPONSE_BODY_REPLACEMENTS.each do | (find, replace) |
      modified_response_body = modified_response_body.gsub(find, replace)
    end

    [response[0], response[1], [modified_response_body]]
  end

end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
pact_broker-2.61.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.60.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.60.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.59.2 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.59.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.59.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.58.3 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.58.2 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.58.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.57.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.56.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.56.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.55.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.54.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.53.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.52.2 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.52.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.52.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.51.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.50.1 spec/service_consumers/hal_relation_proxy_app.rb