Skip to content

Instantly share code, notes, and snippets.

@calebwoods
Created May 20, 2013 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calebwoods/5615260 to your computer and use it in GitHub Desktop.
Save calebwoods/5615260 to your computer and use it in GitHub Desktop.
Testing helper methods to use with Rack::Deflater
def api_post_gziped(url, params={}, api_token = 'test_token')
gzipped_data = ActiveSupport::Gzip.compress(params.to_json)
post(url, gzipped_data, headers.merge('HTTP_AUTHORIZATION' => basic_auth_for(api_token),
"HTTP_ACCEPT_ENCODING" => "gzip",
'CONTENT_TYPE' => 'gzip/json'))
end
def decompressed_json_body
Yajl::Parser.parse(ActiveSupport::Gzip.decompress(response.body))
end
def headers
{ 'CONTENT_TYPE' => 'application/json',
'HTTP_ACCEPT' => 'application/json',
'HTTP_USER_AGENT' => 'Test Client' }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment