On Jun 11, 8:48 pm, Ben Schwarz <
ben.schw...@gmail.com> wrote:
> You can record your responses using curl on the command line:
>
> curl -ihttp://domain.tld> spec/support/domain.tld.curl
>
> Then using fakeweb you can do:
>
> FakeWeb.register_uri(@url, :file => File.join(SPEC_DIR, 'support',
> 'domain.tld.curl'))
There's one other way, right now: you can craft a custom
Net::HTTPResponse object:
fake_response = Net::HTTPOK.new('1.1', '200', 'OK')
fake_response['Content-Type'] = 'application/json'
FakeWeb.register_uri(:get, '
http://example.com', :response =>
fake_response)
response = Net::HTTP.start('
example.com') { |query| query.get('/') }
puts response['Content-Type'] # "application/json"
> Ideally I'm looking to do something like:
>
> FakeWeb.register_uri(@url, :file => File.join(SPEC_DIR, 'support',
> 'domain.tld.curl'), :content_encoding => "gzip")
Sounds good to me!
http://github.com/chrisk/fakeweb/commit/b8fbab47133e3c9089e9218e13a268b9232e1d21
Chris