Sha256: 9c8e076159d0163027b8933aca985a02526a2b8e3c56fa846abd7501e9e55775

Contents?: true

Size: 1.08 KB

Versions: 14

Compression:

Stored size: 1.08 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'
  }

  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

14 entries across 14 versions & 1 rubygems

Version Path
pact_broker-2.23.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.22.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.21.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.20.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.19.2 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.19.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.19.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.18.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.17.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.17.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.16.1 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.16.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.15.0 spec/service_consumers/hal_relation_proxy_app.rb
pact_broker-2.14.0 spec/service_consumers/hal_relation_proxy_app.rb