From 5c4abbde955067055afc9ec5c66b5535d6254f25 Mon Sep 17 00:00:00 2001 From: Elijah Miller Date: Fri, 20 Feb 2009 09:29:54 +0800 Subject: [PATCH] Forcing code to a Fixnum/Integer. Signed-off-by: John Nunemaker --- lib/httparty/response.rb | 2 +- spec/httparty/response_spec.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/httparty/response.rb b/lib/httparty/response.rb index fed575a..0f79caa 100644 --- a/lib/httparty/response.rb +++ b/lib/httparty/response.rb @@ -6,7 +6,7 @@ module HTTParty def initialize(delegate, body, code, headers={}) @delegate = delegate @body = body - @code = code + @code = code.to_i @headers = headers end diff --git a/spec/httparty/response_spec.rb b/spec/httparty/response_spec.rb index aa135d1..b1ffc13 100644 --- a/spec/httparty/response_spec.rb +++ b/spec/httparty/response_spec.rb @@ -5,7 +5,7 @@ describe HTTParty::Response do before do @response_object = {'foo' => 'bar'} @body = "{foo:'bar'}" - @code = 200 + @code = '200' @response = HTTParty::Response.new(@response_object, @body, @code) end @@ -18,7 +18,11 @@ describe HTTParty::Response do end it "should set code" do - @response.code.should == @code + @response.code.should.to_s == @code + end + + it "should set code as a Fixnum" do + @response.code.should be_an_instance_of(Fixnum) end end