spec/rapidash/response_spec.rb in rapidash-0.0.2 vs spec/rapidash/response_spec.rb in rapidash-0.0.3

- old
+ new

@@ -25,14 +25,21 @@ def invalid_response OpenStruct.new({ :headers => { "content-type" => "application/xml" - } + }, + :body => "<xml>something</xml>" }) end +def nil_response + OpenStruct.new({ + :body => nil + }) +end + describe Rapidash::Response do describe "#new" do it "should parse JSON Objects" do response = Rapidash::Response.new(valid_response_object) @@ -41,9 +48,14 @@ it "should parse JSON Arrays" do response = Rapidash::Response.new(valid_response_array) response[0].foo.should eql("bar") response[1].baz.should eql("bra") + end + + it "should return nil if the response has no body" do + response = Rapidash::Response.new(nil_response) + response.should eql(nil) end it "should raise an error on a non-json response" do expect {