Sha256: 83a5a77f5c57bb73450f5af82d2ce36257d2e1df5b0cc2e87a3fb0051f7643fe
Contents?: true
Size: 1.4 KB
Versions: 35
Compression:
Stored size: 1.4 KB
Contents
require 'core/spec_helper' describe ZendeskAPI::Middleware::Response::ParseIsoDates do def fake_response(data) stub_json_request(:get, %r{blergh}, data) response = client.connection.get("blergh") expect(response.status).to eq(200) response end let(:parsed){ if RUBY_VERSION > "1.9" "2012-02-01 13:14:15 UTC" else "Wed Feb 01 13:14:15 UTC 2012" end } it "should parse dates" do expect(fake_response('{"x":"2012-02-01T13:14:15Z"}').body["x"].to_s).to eq(parsed) end it "should parse nested dates in hash" do expect(fake_response('{"x":{"y":"2012-02-01T13:14:15Z"}}').body["x"]["y"].to_s).to eq(parsed) end it "should parse nested dates in arrays" do expect(fake_response('{"x":[{"y":"2012-02-01T13:14:15Z"}]}').body["x"][0]["y"].to_s).to eq(parsed) end it "should not blow up on empty body" do expect(fake_response('').body).to eq('') end it "should leave arrays with ids alone" do expect(fake_response('{"x":[1,2,3]}').body).to eq({"x" => [1,2,3]}) end it "should not parse date-like things" do expect(fake_response('{"x":"2012-02-01T13:14:15Z bla"}').body["x"].to_s).to eq("2012-02-01T13:14:15Z bla") expect(fake_response('{"x":"12012-02-01T13:14:15Z"}').body["x"].to_s).to eq("12012-02-01T13:14:15Z") expect(fake_response(%Q{{"x":"2012-02-01T13:14:15Z\\nfoo"}}).body["x"].to_s).to eq("2012-02-01T13:14:15Z\nfoo") end end
Version data entries
35 entries across 35 versions & 1 rubygems