Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove indirection

  • Loading branch information...
commit 27c4e1c6084cd175b2190b03f42b0f6a55050a8e 1 parent e148e09
@grosser grosser authored
Showing with 8 additions and 13 deletions.
  1. +8 −13 spec/parse_dates_spec.rb
View
21 spec/parse_dates_spec.rb
@@ -3,11 +3,6 @@
require 'json'
describe FaradayMiddleware::ParseDates, :type => :response do
- # simulate the json-parse middleware being in front of this one
- def process(json)
- super(json.strip.empty? ? nil : JSON.parse(json))
- end
-
let(:parsed){
if RUBY_VERSION > "1.9"
"2012-02-01 13:14:15 UTC"
@@ -17,31 +12,31 @@ def process(json)
}
it "should parse dates" do
- process('{"x":"2012-02-01T13:14:15Z"}').body["x"].to_s.should == parsed
+ process({"x" => "2012-02-01T13:14:15Z"}).body["x"].to_s.should == parsed
end
it "should parse nested dates in hash" do
- process('{"x":{"y":"2012-02-01T13:14:15Z"}}').body["x"]["y"].to_s.should == parsed
+ process({"x" => {"y" => "2012-02-01T13:14:15Z"}}).body["x"]["y"].to_s.should == parsed
end
it "should parse nested dates in arrays" do
- process('{"x":[{"y":"2012-02-01T13:14:15Z"}]}').body["x"][0]["y"].to_s.should == parsed
+ process({"x" => [{"y" =>"2012-02-01T13:14:15Z"}]}).body["x"][0]["y"].to_s.should == parsed
end
it "should not blow up on empty body" do
- process('').body.should == nil
+ process(nil).body.should == nil
end
it "should leave arrays with ids alone" do
- process('{"x":[1,2,3]}').body.should == {"x" => [1,2,3]}
+ process({"x" => [1,2,3]}).body.should == {"x" => [1,2,3]}
end
it "should not parse date-like things" do
- process('{"x":"2012-02-01T13:14:15Z bla"}').body["x"].to_s.should ==
+ process({"x" => "2012-02-01T13:14:15Z bla"}).body["x"].to_s.should ==
"2012-02-01T13:14:15Z bla"
- process('{"x":"12012-02-01T13:14:15Z"}').body["x"].to_s.should ==
+ process({"x" => "12012-02-01T13:14:15Z"}).body["x"].to_s.should ==
"12012-02-01T13:14:15Z"
- process(%Q{{"x":"2012-02-01T13:14:15Z\\nfoo"}}).body["x"].to_s.should ==
+ process({"x" => "2012-02-01T13:14:15Z\nfoo"}).body["x"].to_s.should ==
"2012-02-01T13:14:15Z\nfoo"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.