Sha256: 3418c18e186f77c7947b967ca67d8af4e8c026e7f8ad56ce6010dc119d3ae4fc

Contents?: true

Size: 1.19 KB

Versions: 96

Compression:

Stored size: 1.19 KB

Contents

require 'base64'

class Holodeck
  attr_accessor :host, :port

  class Request
    attr_reader :method, :url, :auth, :params, :data, :headers, :any

    def initialize(method: nil, url: nil, auth: nil, params: {}, data: {}, headers: nil, any: false)
      @method = method
      @url = url
      @auth = auth
      @params = params
      @data = data
      @headers = headers
      @any = any
    end

    def any?
      @any
    end

    def ==(other)
      method.casecmp(other.method.upcase).zero? &&
        url == other.url &&
        params == other.params &&
        data == other.data
    end

    def to_s
      "#<Holodeck::Request method:#{method} url:#{url} params:#{params} data:#{data}>"
    end
  end

  ANY = Request.new(any: true)

  def initialize
    @response = nil
    @requests = []
  end

  def mock(response)
    @response = response
  end

  def request(host, port, method, url, params = {}, data = {}, headers = {}, auth = nil, _timeout = nil)
    @requests << Request.new(
      method: method,
      url: url,
      params: params,
      data: data,
      headers: headers,
      auth: auth
    )
    @response
  end

  def has_request?(request)
    @requests.include?(request)
  end
end

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
twilio-ruby-5.38.0 spec/holodeck/holodeck.rb
twilio-ruby-5.37.0 spec/holodeck/holodeck.rb
twilio-ruby-5.36.0 spec/holodeck/holodeck.rb
twilio-ruby-5.35.0 spec/holodeck/holodeck.rb
twilio-ruby-5.34.1 spec/holodeck/holodeck.rb
twilio-ruby-5.34.0 spec/holodeck/holodeck.rb
twilio-ruby-5.33.1 spec/holodeck/holodeck.rb
twilio-ruby-5.33.0 spec/holodeck/holodeck.rb
twilio-ruby-5.32.0 spec/holodeck/holodeck.rb
twilio-ruby-5.31.6 spec/holodeck/holodeck.rb
twilio-ruby-5.31.5 spec/holodeck/holodeck.rb
twilio-ruby-5.31.4 spec/holodeck/holodeck.rb
twilio-ruby-5.31.3 spec/holodeck/holodeck.rb
twilio-ruby-5.31.2 spec/holodeck/holodeck.rb
twilio-ruby-5.31.1 spec/holodeck/holodeck.rb
twilio-ruby-5.31.0 spec/holodeck/holodeck.rb
twilio-ruby-5.30.0 spec/holodeck/holodeck.rb
twilio-ruby-5.29.1 spec/holodeck/holodeck.rb
twilio-ruby-5.29.0 spec/holodeck/holodeck.rb
twilio-ruby-5.28.0 spec/holodeck/holodeck.rb