Pregunta

Is there a way to mock out Curb's Easy.perform method for unit testing? I use this to hit Facebook's graph API, and none of the http mock libs seem to support Curb.

What's the best approach here?

¿Fue útil?

Solución

WebMock has recently added Curb support. :)

http://github.com/bblimke/webmock

Otros consejos

I really think fakeWeb is a great way to fake out network calls; Whatever HTTP library you use, you'll just specify what response text and code you want to receive.

Described as:

FakeWeb is a helper for faking web requests in Ruby. It works at a global level, without modifying code or writing extensive stubs

Example from the github repository:

FakeWeb.register_uri(:get, "http://example.com/test1", :string => "Hello World!")

Net::HTTP.get(URI.parse("http://example.com/test1"))
=> "Hello World!"

Net::HTTP.get(URI.parse("http://example.com/test2"))
=> FakeWeb is bypassed and the response from a real request is returned
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top