Sha256: a5f674da3c6c840bde55e24ed60dac24392b0a368c59edfd23956e8768ca7157
Contents?: true
Size: 899 Bytes
Versions: 20
Compression:
Stored size: 899 Bytes
Contents
require "spec_helper" require "multi_xml" describe ApiClient::Base do it "parses json if json is set as format" do ApiClient::Base.stub(:format).and_return(:json) parsed = ApiClient::Base.parse('{"a":"1"}') parsed.should == {"a"=> "1"} end it "parses xml if xml is set as format" do ApiClient::Base.stub(:format).and_return(:xml) parsed = ApiClient::Base.parse('<a>1</a>') parsed.should == {"a"=> "1"} end it "returns the string if parser is not found" do ApiClient::Base.stub(:format).and_return(:unknown) parsed = ApiClient::Base.parse('a:1') parsed.should == "a:1" end it "extracts the body of a Faraday::Response if it is provided" do response = Faraday::Response.new(:body => '{"a": "1"}') ApiClient::Base.stub(:format).and_return(:json) parsed = ApiClient::Base.parse(response) parsed.should == {"a"=> "1"} end end
Version data entries
20 entries across 20 versions & 1 rubygems