Sha256: b174a203fb904320e38a4aa86be450f593ed0ae2a74148dfe152daab4685fe56

Contents?: true

Size: 1.17 KB

Versions: 24

Compression:

Stored size: 1.17 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.upcase == other.method.upcase &&
      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
    )
    return @response
  end

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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
twilio-ruby-5.0.0.rc26 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc25 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc24 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc23 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc22 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc21 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc20 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc19 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc18 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc17 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc16 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc15 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc14 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc13 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc12 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc11 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc10 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc9 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc8 spec/holodeck/holodeck.rb
twilio-ruby-5.0.0.rc7 spec/holodeck/holodeck.rb