mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Fixed tests
This commit is contained in:
parent
77a965c634
commit
f7b1645383
5 changed files with 14 additions and 8 deletions
|
@ -4,6 +4,10 @@ module RestClient
|
|||
|
||||
attr_reader :net_http_res
|
||||
|
||||
def initialize net_http_res
|
||||
@net_http_res = net_http_res
|
||||
end
|
||||
|
||||
# HTTP status code
|
||||
def code
|
||||
@code ||= @net_http_res.code.to_i
|
||||
|
|
|
@ -13,8 +13,8 @@ module RestClient
|
|||
|
||||
attr_reader :file
|
||||
|
||||
def initialize(tempfile, net_http_res)
|
||||
@net_http_res = net_http_res
|
||||
def initialize tempfile, net_http_res
|
||||
super net_http_res
|
||||
@file = tempfile
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ module RestClient
|
|||
|
||||
attr_reader :body
|
||||
|
||||
def initialize(body, net_http_res)
|
||||
@net_http_res = net_http_res
|
||||
def initialize body, net_http_res
|
||||
super net_http_res
|
||||
@body = body || ""
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/base'
|
|||
describe RestClient::AbstractResponse do
|
||||
before do
|
||||
@net_http_res = mock('net http response')
|
||||
@response = AbstractResponse.new('abc', @net_http_res)
|
||||
@response = RestClient::AbstractResponse.new(@net_http_res)
|
||||
end
|
||||
|
||||
it "fetches the numeric response code" do
|
||||
|
|
|
@ -60,9 +60,11 @@ describe RestClient::Response do
|
|||
|
||||
it "should throw an exception for other codes" do
|
||||
RestClient::Exceptions::EXCEPTIONS_MAP.each_key do |code|
|
||||
net_http_res = mock('net http response', :code => code.to_i)
|
||||
response = RestClient::Response.new('abc', net_http_res)
|
||||
lambda { response.return!}.should raise_error
|
||||
unless (200..206).include? code
|
||||
net_http_res = mock('net http response', :code => code.to_i)
|
||||
response = RestClient::Response.new('abc', net_http_res)
|
||||
lambda { response.return!}.should raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue