Skip to content

Instantly share code, notes, and snippets.

@foeken
Created September 3, 2008 06:56
Show Gist options
  • Save foeken/8553 to your computer and use it in GitHub Desktop.
Save foeken/8553 to your computer and use it in GitHub Desktop.
Simple Net::Http Mock
class Net::HTTP < Net::Protocol
def connect
end
end
class Net::HTTPResponse
def body=(content)
@body = content
@read = true
end
end
class Net::HTTP < Net::Protocol
mattr_accessor :xml_data
def post(path, body, headers)
raise "Broken mock" if !self.xml_data
res = Net::HTTPSuccess.new('1.2', '200', 'OK')
res.body = self.xml_data
return res
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment