This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Typhoeus::Response::Header do
|
||||
let(:raw) { nil }
|
||||
let(:header) { Typhoeus::Response::Header.new(raw) }
|
||||
|
||||
describe ".new" do
|
||||
context "when string" do
|
||||
let(:raw) { 'Date: Fri, 29 Jun 2012 10:09:23 GMT' }
|
||||
|
||||
it "sets Date" do
|
||||
expect(header['Date']).to eq('Fri, 29 Jun 2012 10:09:23 GMT')
|
||||
end
|
||||
|
||||
it "provides case insensitive access" do
|
||||
expect(header['DaTe']).to eq('Fri, 29 Jun 2012 10:09:23 GMT')
|
||||
end
|
||||
|
||||
it "provides symbol access" do
|
||||
expect(header[:date]).to eq('Fri, 29 Jun 2012 10:09:23 GMT')
|
||||
end
|
||||
end
|
||||
|
||||
context "when hash" do
|
||||
let(:raw) { { 'Date' => 'Fri, 29 Jun 2012 10:09:23 GMT' } }
|
||||
|
||||
it "sets Date" do
|
||||
expect(header['Date']).to eq(raw['Date'])
|
||||
end
|
||||
|
||||
it "provides case insensitive access" do
|
||||
expect(header['DaTe']).to eq(raw['Date'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#parse" do
|
||||
context "when no header" do
|
||||
it "returns nil" do
|
||||
expect(header).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "when header" do
|
||||
let(:raw) do
|
||||
'HTTP/1.1 200 OK
|
||||
Set-Cookie: NID=61=LblqYgUOu; expires=Sat, 29-Dec-2012 10:09:23 GMT; path=/; domain=.google.de; HttpOnly
|
||||
Date: Fri, 29 Jun 2012 10:09:23 GMT
|
||||
Expires: -1
|
||||
Cache-Control: private, max-age=0
|
||||
Content-Type: text/html; charset=ISO-8859-1
|
||||
Set-Cookie: PREF=ID=77e93yv0hPtejLou; expires=Sun, 29-Jun-2014 10:09:23 GMT; path=/; domain=.google.de
|
||||
Set-Cookie: NID=61=LblqYgh5Ou; expires=Sat, 29-Dec-2012 10:09:23 GMT; path=/; domain=.google.de; HttpOnly
|
||||
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
|
||||
Server: gws
|
||||
X-XSS-Protection: 1; mode=block
|
||||
X-Frame-Options: SAMEORIGIN
|
||||
Transfer-Encoding: chunked'.gsub(/^\s{8}/, '')
|
||||
end
|
||||
|
||||
it "sets raw" do
|
||||
expect(header.send(:raw)).to eq(raw)
|
||||
end
|
||||
|
||||
it "sets Set-Cookie" do
|
||||
expect(header['set-cookie'].size).to eq(3)
|
||||
end
|
||||
|
||||
it "provides case insensitive access" do
|
||||
expect(header['Set-CooKie'].size).to eq(3)
|
||||
end
|
||||
|
||||
[
|
||||
'NID=61=LblqYgUOu; expires=Sat, 29-Dec-2012 10:09:23 GMT; path=/; domain=.google.de; HttpOnly',
|
||||
'PREF=ID=77e93yv0hPtejLou; expires=Sun, 29-Jun-2014 10:09:23 GMT; path=/; domain=.google.de',
|
||||
'NID=61=LblqYgh5Ou; expires=Sat, 29-Dec-2012 10:09:23 GMT; path=/; domain=.google.de; HttpOnly'
|
||||
].each_with_index do |cookie, i|
|
||||
it "sets Cookie##{i}" do
|
||||
expect(header['set-cookie']).to include(cookie)
|
||||
end
|
||||
end
|
||||
|
||||
{
|
||||
'Date' => 'Fri, 29 Jun 2012 10:09:23 GMT', 'Expires' => '-1',
|
||||
'Cache-Control' => 'private, max-age=0',
|
||||
'Content-Type' => 'text/html; charset=ISO-8859-1',
|
||||
'P3P' => 'CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."',
|
||||
'Server' => 'gws', 'X-XSS-Protection' => '1; mode=block',
|
||||
'X-Frame-Options' => 'SAMEORIGIN', 'Transfer-Encoding' => 'chunked'
|
||||
}.each do |name, value|
|
||||
it "sets #{name}" do
|
||||
expect(header[name.downcase]).to eq(value)
|
||||
end
|
||||
end
|
||||
|
||||
context 'includes a multi-line header' do
|
||||
let(:raw) do
|
||||
'HTTP/1.1 200 OK
|
||||
Date: Fri, 29 Jun 2012 10:09:23 GMT
|
||||
Content-Security-Policy: default-src "self";
|
||||
img-src * data: "self";
|
||||
upgrade-insecure-requests;'.gsub(/^\s{10}/, '')
|
||||
end
|
||||
|
||||
it "joins header parts" do
|
||||
expect(header).to eq({
|
||||
'Date' => 'Fri, 29 Jun 2012 10:09:23 GMT',
|
||||
'Content-Security-Policy' => 'default-src "self"; img-src * data: "self"; upgrade-insecure-requests;'
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'includes line with only whitespace' do
|
||||
let(:raw) do
|
||||
'HTTP/1.1 200 OK
|
||||
Date: Fri, 29 Jun 2012 10:09:23 GMT
|
||||
|
||||
'.gsub(/^\s{10}/, '')
|
||||
end
|
||||
|
||||
it 'ignores it' do
|
||||
expect(header).to eq({ 'Date' => 'Fri, 29 Jun 2012 10:09:23 GMT' })
|
||||
end
|
||||
end
|
||||
|
||||
context 'with broken headers' do
|
||||
let(:raw) do
|
||||
'HTTP/1.1 200 OK
|
||||
Date:
|
||||
Content-Type
|
||||
'.gsub(/^\s{10}/, '')
|
||||
end
|
||||
|
||||
it 'returns empty string for invalid headers' do
|
||||
expect(header.to_hash).to include({ 'Date' => '', 'Content-Type' => '' })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "can be Marshal'd" do
|
||||
header = Typhoeus::Response::Header.new("Foo: Bar")
|
||||
expect {
|
||||
Marshal.dump(header)
|
||||
}.not_to raise_error
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,323 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Typhoeus::Response::Informations do
|
||||
let(:options) { {} }
|
||||
let(:response) { Typhoeus::Response.new(options) }
|
||||
|
||||
describe "#return_code" do
|
||||
let(:options) { { :return_code => :ok } }
|
||||
|
||||
it "returns return_code from options" do
|
||||
expect(response.return_code).to be(:ok)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#debug_info" do
|
||||
let(:options) { { :debug_info => Ethon::Easy::DebugInfo.new } }
|
||||
|
||||
it "returns debug_info from options" do
|
||||
expect(response.debug_info).to be_a(Ethon::Easy::DebugInfo)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#return_message" do
|
||||
let(:options) { { :return_code => :couldnt_connect } }
|
||||
|
||||
it "returns a message" do
|
||||
expect(response.return_message).to eq("Couldn't connect to server")
|
||||
end
|
||||
|
||||
describe "with nil return_code" do
|
||||
let(:options) { { :return_code => nil } }
|
||||
|
||||
it "returns nil" do
|
||||
expect(response.return_message).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#response_body" do
|
||||
context "when response_body" do
|
||||
let(:options) { { :response_body => "body" } }
|
||||
|
||||
it "returns response_body from options" do
|
||||
expect(response.response_body).to eq("body")
|
||||
end
|
||||
end
|
||||
|
||||
context "when body" do
|
||||
let(:options) { { :body => "body" } }
|
||||
|
||||
it "returns body from options" do
|
||||
expect(response.body).to eq("body")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#response_headers" do
|
||||
let(:options) { { :response_headers => "Length: 1" } }
|
||||
|
||||
context "when no mock" do
|
||||
it "returns response_headers from options" do
|
||||
expect(response.response_headers).to eq("Length: 1")
|
||||
end
|
||||
end
|
||||
|
||||
context "when mock" do
|
||||
context "when no response_headers" do
|
||||
context "when headers" do
|
||||
let(:options) { { :mock => true, :headers => {"Length" => 1, "Content-Type" => "text/plain" } } }
|
||||
|
||||
it "constructs response_headers" do
|
||||
expect(response.response_headers).to include("Length: 1")
|
||||
expect(response.response_headers).to include("Content-Type: text/plain")
|
||||
expect(response.response_headers).to include("\r\n")
|
||||
end
|
||||
end
|
||||
|
||||
context "when multiple values for a header" do
|
||||
let(:options) { { :mock => true, :headers => {"Length" => 1, "Content-Type" => "text/plain", "set-cookie" => ["cookieone=one","cookietwo=two"] } } }
|
||||
|
||||
it "constructs response_headers" do
|
||||
expect(response.response_headers).to include("Length: 1")
|
||||
expect(response.response_headers).to include("Content-Type: text/plain")
|
||||
expect(response.response_headers).to include("set-cookie: cookieone=one,cookietwo=two")
|
||||
expect(response.response_headers).to include("\r\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#response_code" do
|
||||
context "when response_code" do
|
||||
let(:options) { { :response_code => "200" } }
|
||||
|
||||
it "returns response_code from options" do
|
||||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
context "when code" do
|
||||
let(:options) { { :code => "200" } }
|
||||
|
||||
it "returns code from options" do
|
||||
expect(response.code).to eq(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#httpauth_avail" do
|
||||
let(:options) { { :httpauth_avail => "code" } }
|
||||
|
||||
it "returns httpauth_avail from options" do
|
||||
expect(response.httpauth_avail).to eq("code")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#total_time" do
|
||||
let(:options) { { :total_time => 1 } }
|
||||
|
||||
it "returns total_time from options" do
|
||||
expect(response.total_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#starttransfer_time" do
|
||||
let(:options) { { :starttransfer_time => 1 } }
|
||||
|
||||
it "returns starttransfer_time from options" do
|
||||
expect(response.starttransfer_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#appconnect_time" do
|
||||
let(:options) { { :appconnect_time => 1 } }
|
||||
|
||||
it "returns appconnect_time from options" do
|
||||
expect(response.appconnect_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#pretransfer_time" do
|
||||
let(:options) { { :pretransfer_time => 1 } }
|
||||
|
||||
it "returns pretransfer_time from options" do
|
||||
expect(response.pretransfer_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#connect_time" do
|
||||
let(:options) { { :connect_time => 1 } }
|
||||
|
||||
it "returns connect_time from options" do
|
||||
expect(response.connect_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#namelookup_time" do
|
||||
let(:options) { { :namelookup_time => 1 } }
|
||||
|
||||
it "returns namelookup_time from options" do
|
||||
expect(response.namelookup_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redirect_time" do
|
||||
let(:options) { { :redirect_time => 1 } }
|
||||
|
||||
it "returns redirect_time from options" do
|
||||
expect(response.redirect_time).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#effective_url" do
|
||||
let(:options) { { :effective_url => "http://www.example.com" } }
|
||||
|
||||
it "returns effective_url from options" do
|
||||
expect(response.effective_url).to eq("http://www.example.com")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#primary_ip" do
|
||||
let(:options) { { :primary_ip => "127.0.0.1" } }
|
||||
|
||||
it "returns primary_ip from options" do
|
||||
expect(response.primary_ip).to eq("127.0.0.1")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redirect_count" do
|
||||
let(:options) { { :redirect_count => 2 } }
|
||||
|
||||
it "returns redirect_count from options" do
|
||||
expect(response.redirect_count).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redirect_url" do
|
||||
let(:options) { { :redirect_url => "http://www.example.com" } }
|
||||
|
||||
it "returns redirect_url from options" do
|
||||
expect(response.redirect_url).to eq("http://www.example.com")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#request_size" do
|
||||
let(:options) { { :request_size => 2 } }
|
||||
|
||||
it "returns request_size from options" do
|
||||
expect(response.request_size).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#size_upload" do
|
||||
let(:options) { { :size_upload => 2.0 } }
|
||||
|
||||
it "returns size_upload from options" do
|
||||
expect(response.size_upload).to eq(2.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#size_download" do
|
||||
let(:options) { { :size_download => 2.0 } }
|
||||
|
||||
it "returns size_download from options" do
|
||||
expect(response.size_download).to eq(2.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#speed_upload" do
|
||||
let(:options) { { :speed_upload => 2.0 } }
|
||||
|
||||
it "returns speed_upload from options" do
|
||||
expect(response.speed_upload).to eq(2.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#speed_download" do
|
||||
let(:options) { { :speed_download => 2.0 } }
|
||||
|
||||
it "returns speed_download from options" do
|
||||
expect(response.speed_download).to eq(2.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#headers" do
|
||||
context "when no response_headers" do
|
||||
it "returns nil" do
|
||||
expect(response.headers).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when response_headers" do
|
||||
let(:options) { {:response_headers => "Expire: -1\nServer: gws"} }
|
||||
|
||||
it "returns nonempty headers" do
|
||||
expect(response.headers).to_not be_empty
|
||||
end
|
||||
|
||||
it "has Expire" do
|
||||
expect(response.headers['expire']).to eq('-1')
|
||||
end
|
||||
|
||||
it "has Server" do
|
||||
expect(response.headers['server']).to eq('gws')
|
||||
end
|
||||
end
|
||||
|
||||
context "when multiple headers" do
|
||||
let(:options) { {:response_headers => "Server: A\r\n\r\nServer: B"} }
|
||||
|
||||
it "returns the last" do
|
||||
expect(response.headers['server']).to eq("B")
|
||||
end
|
||||
end
|
||||
|
||||
context "when mock" do
|
||||
context "when headers" do
|
||||
let(:options) { {:mock => true, :headers => {"Length" => "1"}} }
|
||||
|
||||
it "returns Typhoeus::Response::Header" do
|
||||
expect(response.headers).to be_a(Typhoeus::Response::Header)
|
||||
end
|
||||
|
||||
it "returns headers" do
|
||||
expect(response.headers.to_hash).to include("Length" => "1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when requesting" do
|
||||
let(:response) { Typhoeus.get("localhost:3001") }
|
||||
|
||||
it "returns headers" do
|
||||
expect(response.headers).to_not be_empty
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#redirections" do
|
||||
context "when no response_headers" do
|
||||
it "returns empty array" do
|
||||
expect(response.redirections).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "when headers" do
|
||||
let(:options) { {:response_headers => "Expire: -1\nServer: gws"} }
|
||||
|
||||
it "returns empty array" do
|
||||
expect(response.redirections).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context "when multiple headers" do
|
||||
let(:options) { {:response_headers => "Server: A\r\n\r\nServer: B"} }
|
||||
|
||||
it "returns response from all but last headers" do
|
||||
expect(response.redirections.size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,256 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Typhoeus::Response::Status do
|
||||
let(:response) { Typhoeus::Response.new(options) }
|
||||
let(:options) { {} }
|
||||
|
||||
describe "timed_out?" do
|
||||
context "when return code is operation_timedout" do
|
||||
let(:options) { {:return_code => :operation_timedout} }
|
||||
|
||||
it "return true" do
|
||||
expect(response).to be_timed_out
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#status_message" do
|
||||
context "when no header" do
|
||||
it "returns nil" do
|
||||
expect(response.status_message).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when header" do
|
||||
context "when no message" do
|
||||
let(:options) { {:response_headers => "HTTP/1.1 200\r\n"} }
|
||||
|
||||
it "returns nil" do
|
||||
expect(response.status_message).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when messsage" do
|
||||
let(:options) { {:response_headers => "HTTP/1.1 200 message\r\n"} }
|
||||
|
||||
it "returns message" do
|
||||
expect(response.status_message).to eq("message")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#http_version" do
|
||||
context "when no header" do
|
||||
it "returns nil" do
|
||||
expect(response.http_version).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when header" do
|
||||
context "when no http version" do
|
||||
let(:options) { {:response_headers => "HTTP OK"} }
|
||||
|
||||
it "returns nil" do
|
||||
expect(response.http_version).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when invalid http_version" do
|
||||
let(:options) { {:response_headers => "HTTP foo/bar OK"} }
|
||||
|
||||
it "returns nil" do
|
||||
expect(response.http_version).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when valid http_version" do
|
||||
let(:options) { {:response_headers => "HTTP/1.1 OK"} }
|
||||
|
||||
it "returns http_version" do
|
||||
expect(response.http_version).to eq("1.1")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#success?" do
|
||||
context "when response code 200-299" do
|
||||
let(:options) { {:return_code => return_code, :response_code => 201} }
|
||||
|
||||
context "when mock" do
|
||||
before { response.mock = true }
|
||||
|
||||
context "when return_code :ok" do
|
||||
let(:return_code) { :ok }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.success?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.success?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when no mock" do
|
||||
before { response.mock = nil }
|
||||
|
||||
context "when return_code :ok" do
|
||||
let(:return_code) { :ok }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.success?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.success?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when response code is not 200-299" do
|
||||
let(:options) { {:return_code => :ok, :response_code => 500} }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.success?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#failure?" do
|
||||
context "when response code between 300-526 and 100-300" do
|
||||
let(:options) { {:return_code => return_code, :response_code => 300} }
|
||||
|
||||
context "when mock" do
|
||||
before { response.mock = true }
|
||||
|
||||
context "when return_code :internal_server_error" do
|
||||
let(:return_code) { :internal_server_error }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.failure?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.failure?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when no mock" do
|
||||
before { response.mock = nil }
|
||||
|
||||
context "when return_code :internal_server_error" do
|
||||
let(:return_code) { :internal_server_error }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.failure?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.failure?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when response code is not 300-526" do
|
||||
let(:options) { {:return_code => :ok, :response_code => 200} }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.failure?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#modified?" do
|
||||
context "when response code 304" do
|
||||
let(:options) { {:return_code => :ok, :response_code => 304} }
|
||||
|
||||
context "when mock" do
|
||||
before { response.mock = true }
|
||||
|
||||
context "when return_code :ok" do
|
||||
let(:return_code) { :ok }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.modified?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.modified?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when no mock" do
|
||||
before { response.mock = nil }
|
||||
|
||||
context "when return_code :ok" do
|
||||
let(:return_code) { :ok }
|
||||
|
||||
it "returns false" do
|
||||
expect(response.modified?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "when return_code nil" do
|
||||
let(:return_code) { nil }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.modified?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when response code is not 304" do
|
||||
let(:options) { {:return_code => :ok, :response_code => 500} }
|
||||
|
||||
it "returns true" do
|
||||
expect(response.modified?).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#first_header_line" do
|
||||
context "when multiple header" do
|
||||
let(:options) { {:response_headers => "1\r\n\r\n2\r\nbla"} }
|
||||
|
||||
it "returns first line of last block" do
|
||||
expect(response.method(:first_header_line).call).to eq("2")
|
||||
end
|
||||
end
|
||||
|
||||
context "when single header" do
|
||||
let(:options) { {:response_headers => "1"} }
|
||||
|
||||
it "returns first line" do
|
||||
expect(response.method(:first_header_line).call).to eq("1")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user