api_resource 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,11 @@ module ApiResource
18
18
  end
19
19
 
20
20
  def decode(json)
21
- JSON.parse(json)
21
+ if json.strip.blank?
22
+ return {}
23
+ else
24
+ JSON.parse(json)
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -1,3 +1,3 @@
1
1
  module ApiResource
2
- VERSION = "0.6.11"
2
+ VERSION = "0.6.12"
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ApiResource::Formats::JsonFormat do
4
+
5
+
6
+ context "#decode" do
7
+
8
+ it "should not err on a blank response from an api" do
9
+
10
+ blank_str = " \n "
11
+ lambda{
12
+ subject.decode(blank_str)
13
+ }.should_not raise_error
14
+
15
+ end
16
+
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-09-18 00:00:00.000000000 Z
14
+ date: 2013-09-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -437,6 +437,7 @@ files:
437
437
  - spec/lib/finders/resource_finder_spec.rb
438
438
  - spec/lib/finders/single_object_association_finder_spec.rb
439
439
  - spec/lib/finders_spec.rb
440
+ - spec/lib/formats/json_format_spec.rb
440
441
  - spec/lib/local_spec.rb
441
442
  - spec/lib/mocks_spec.rb
442
443
  - spec/lib/model_errors_spec.rb
@@ -472,18 +473,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
472
473
  - - ! '>='
473
474
  - !ruby/object:Gem::Version
474
475
  version: '0'
475
- segments:
476
- - 0
477
- hash: -1711594839085800941
478
476
  required_rubygems_version: !ruby/object:Gem::Requirement
479
477
  none: false
480
478
  requirements:
481
479
  - - ! '>='
482
480
  - !ruby/object:Gem::Version
483
481
  version: '0'
484
- segments:
485
- - 0
486
- hash: -1711594839085800941
487
482
  requirements: []
488
483
  rubyforge_project:
489
484
  rubygems_version: 1.8.25
@@ -506,6 +501,7 @@ test_files:
506
501
  - spec/lib/finders/resource_finder_spec.rb
507
502
  - spec/lib/finders/single_object_association_finder_spec.rb
508
503
  - spec/lib/finders_spec.rb
504
+ - spec/lib/formats/json_format_spec.rb
509
505
  - spec/lib/local_spec.rb
510
506
  - spec/lib/mocks_spec.rb
511
507
  - spec/lib/model_errors_spec.rb