Sha256: 1239c5c83d1b03972bd61c17d66268c88dea8873b895137c5248120863f101b9
Contents?: true
Size: 1.4 KB
Versions: 1
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(nil) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zendesk_api-1.4.0 | spec/core/middleware/response/parse_iso_dates_spec.rb |