class Net::HTTP

Attributes

params[RW]

Records submitted POST params

paths[RW]

Records POST paths

responses[RW]

Holds POST body responses

Public Instance Methods

request(req) click to toggle source

Override #request to fake its results

# File lib/rc_rest/net_http_stub.rb, line 54
def request(req)
  self.class.paths << req.path
  self.class.params << req.body
  response = self.class.responses.shift
  if response.respond_to? :call then
    response.call req
  else
    res = Net::HTTPResponse.new '1.0', 200, 'OK'
    res.body = response
    res
  end
end

Public Class Methods

start(host, port) { |http| ... } click to toggle source

Override ::start to not connect

# File lib/rc_rest/net_http_stub.rb, line 45
def self.start(host, port)
  yield Net::HTTP.new(host)
end