Sha256: f9c2b88c111884fcf8e3806f63ef20a93835633f6a958209b7af94c294249e57
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' describe ApiClient::Parser do describe "#_response" do context "with a valid json response" do 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 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 FakeWeb.register_uri(:post, "http://api.example.com/user/5", :body => "wrong", :status => "201") @response = ApiClient::Base._post('http://api.example.com/user/5', {}, {}) end it "should return the response code and a nil body" do ApiClient::Base._response(@response).should == ['201', nil] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
api-client-1.4.1 | spec/api-client/parser_spec.rb |
api-client-1.4.0 | spec/api-client/parser_spec.rb |
api-client-1.3.0 | spec/api-client/parser_spec.rb |