Sha256: ae441ff2873951300be2e9936bcd27b7b44e1535a07d56287e9439ffe8bf2603
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'json' require "spec_helper" def valid_response_object body = {"foo" => "bar" }.to_json OpenStruct.new({ :headers => { "content-type" => "application/json" }, :body => body }) end def valid_response_array body = [{"foo" => "bar" }, {"baz" => "bra"}].to_json OpenStruct.new({ :headers => { "content-type" => "application/json" }, :body => body }) end def invalid_response OpenStruct.new({ :headers => { "content-type" => "application/xml" } }) end describe Rapidash::Response do describe "#new" do it "should parse JSON Objects" do response = Rapidash::Response.new(valid_response_object) response.foo.should eql("bar") end 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 raise an error on a non-json response" do expect { Rapidash::Response.new(invalid_response) }.to raise_error(Rapidash::ParseError) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rapidash-0.0.2 | spec/rapidash/response_spec.rb |
rapidash-0.0.1 | spec/rapidash/response_spec.rb |