1
0
Fork 0
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:
Julien Kirch 2010-01-27 23:07:03 +01:00
parent 77a965c634
commit f7b1645383
5 changed files with 14 additions and 8 deletions

View file

@ -4,6 +4,10 @@ module RestClient
attr_reader :net_http_res attr_reader :net_http_res
def initialize net_http_res
@net_http_res = net_http_res
end
# HTTP status code # HTTP status code
def code def code
@code ||= @net_http_res.code.to_i @code ||= @net_http_res.code.to_i

View file

@ -13,8 +13,8 @@ module RestClient
attr_reader :file attr_reader :file
def initialize(tempfile, net_http_res) def initialize tempfile, net_http_res
@net_http_res = net_http_res super net_http_res
@file = tempfile @file = tempfile
end end

View file

@ -6,8 +6,8 @@ module RestClient
attr_reader :body attr_reader :body
def initialize(body, net_http_res) def initialize body, net_http_res
@net_http_res = net_http_res super net_http_res
@body = body || "" @body = body || ""
end end

View file

@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/base'
describe RestClient::AbstractResponse do describe RestClient::AbstractResponse do
before do before do
@net_http_res = mock('net http response') @net_http_res = mock('net http response')
@response = AbstractResponse.new('abc', @net_http_res) @response = RestClient::AbstractResponse.new(@net_http_res)
end end
it "fetches the numeric response code" do it "fetches the numeric response code" do

View file

@ -60,9 +60,11 @@ describe RestClient::Response do
it "should throw an exception for other codes" do it "should throw an exception for other codes" do
RestClient::Exceptions::EXCEPTIONS_MAP.each_key do |code| RestClient::Exceptions::EXCEPTIONS_MAP.each_key do |code|
net_http_res = mock('net http response', :code => code.to_i) unless (200..206).include? code
response = RestClient::Response.new('abc', net_http_res) net_http_res = mock('net http response', :code => code.to_i)
lambda { response.return!}.should raise_error response = RestClient::Response.new('abc', net_http_res)
lambda { response.return!}.should raise_error
end
end end
end end