mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
Added cucumber tests for HEAD request to gzipped asset.
This commit is contained in:
parent
6d3f18c103
commit
4797c7696d
3 changed files with 25 additions and 2 deletions
|
@ -17,3 +17,11 @@ Feature: Handles Compressed Responses
|
|||
And that service is accessed at the path '/gzip_service.html'
|
||||
When I call HTTParty#get with '/gzip_service.html'
|
||||
Then the return value should match '<h1>Some HTML</h1>'
|
||||
|
||||
Scenario: Supports HEAD request with gzip encoding
|
||||
Given a remote gzip service
|
||||
And that service is accessed at the path '/gzip_head.gz.js'
|
||||
When I call HTTParty#head with '/gzip_head.gz.js'
|
||||
Then it should return a response with a 200 response code
|
||||
Then it should return a response with a gzip content-encoding
|
||||
Then it should return a response with a blank body
|
||||
|
|
|
@ -11,7 +11,6 @@ def constantize(camel_cased_word)
|
|||
constant
|
||||
end
|
||||
|
||||
|
||||
Then /it should return an? (\w+)$/ do |class_string|
|
||||
@response_from_httparty.should be_an_instance_of(class_string.class)
|
||||
end
|
||||
|
@ -34,6 +33,14 @@ Then /it should return a response with a (\d+) response code/ do |code|
|
|||
@response_from_httparty.code.should eql(code.to_i)
|
||||
end
|
||||
|
||||
Then /it should return a response with a (.*) content\-encoding$/ do |content_type|
|
||||
@response_from_httparty.headers['content-encoding'].should eql('gzip')
|
||||
end
|
||||
|
||||
Then /it should return a response with a blank body$/ do
|
||||
@response_from_httparty.body.should be(nil)
|
||||
end
|
||||
|
||||
Then /it should raise (?:an|a) ([\w:]+) exception/ do |exception|
|
||||
@exception_from_httparty.should_not be_nil
|
||||
@exception_from_httparty.should be_a constantize(exception)
|
||||
|
|
|
@ -10,6 +10,14 @@ When /I call HTTParty#get with '(.*)'$/ do |url|
|
|||
end
|
||||
end
|
||||
|
||||
When /^I call HTTParty#head with '(.*)'$/ do |url|
|
||||
begin
|
||||
@response_from_httparty = HTTParty.head("http://#{@host_and_port}#{url}", @request_options)
|
||||
rescue HTTParty::RedirectionTooDeep, Timeout::Error => e
|
||||
@exception_from_httparty = e
|
||||
end
|
||||
end
|
||||
|
||||
When /I call HTTParty#get with '(.*)' and a basic_auth hash:/ do |url, auth_table|
|
||||
h = auth_table.hashes.first
|
||||
@response_from_httparty = HTTParty.get(
|
||||
|
@ -24,4 +32,4 @@ When /I call HTTParty#get with '(.*)' and a digest_auth hash:/ do |url, auth_tab
|
|||
"http://#{@host_and_port}#{url}",
|
||||
:digest_auth => { :username => h["username"], :password => h["password"] }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue