spec/api-client/parser_spec.rb in api-client-1.2.0 vs spec/api-client/parser_spec.rb in api-client-1.3.0

- old
+ new

@@ -1,18 +1,33 @@ require 'spec_helper' describe ApiClient::Parser do describe "#_response" do context "with a valid json response" do - before :each do - FakeWeb.register_uri(:post, "http://api.example.com/user/5", - :body => { :a => :b }.to_json, - :status => "201") - @response = ApiClient::Base._post('http://api.example.com/user/5', {}, {}) + context "without a root node" do + before :each do + FakeWeb.register_uri(:post, "http://api.example.com/user/5", + :body => { :a => :b }.to_json, + :status => "201") + @response = ApiClient::Base._post('http://api.example.com/user/5', {}, {}) + end + + it "should return the response code and the body parsed" do + ApiClient::Base._response(@response).should == ['201', { "a" => "b" }] + end end - it "should return the response code and the body parsed" do - ApiClient::Base._response(@response).should == ['201', { "a" => "b" }] + context "with a root node" do + before :each do + FakeWeb.register_uri(:post, "http://api.example.com/user/5", + :body => { :base => { :a => :b } }.to_json, + :status => "201") + @response = ApiClient::Base._post('http://api.example.com/user/5', {}, {}) + end + + it "should return the response code and the body parsed" do + ApiClient::Base._response(@response).should == ['201', { "a" => "b" }] + end end end context "with a invalid json response" do before :each do \ No newline at end of file