Sha256: 304e65ce243339c6d41f16be4500aa108e190d15a0b71d4115556f74daa8c220

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

module Tracksale
  class DummyClient
    class << self
      attr_accessor :response # Easy way to force a response
    end

    def initialize
      puts 'running tracksale dummy client, do not expect real responses.' if $DEBUG
    end

    # maintaining the same method signature as the real client
    def get(_endpoint_path, _extra_headers = {})
      response
    end

    # maintaining the same method signature as the real client
    def post(_endpoint_path, _body, _extra_headers = {})
      response
    end

    def default_response_object
      response = {}

      def response.success?
        true
      end

      response
    end

    def response
      # definies a default valid response unless explicity defined.
      self.class.response || default_response_object
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tracksale-0.0.7 lib/tracksale/dummy_client.rb
tracksale-0.0.5 lib/tracksale/dummy_client.rb