tco_client_core 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a06f11ee66ae3e0e9d4fab6f00c0e923461baa48
4
- data.tar.gz: 437730372295d925701bb287ca233faf7afb65c5
3
+ metadata.gz: 1fba66273191b0a4c9ce439c6ce0a12b64a05152
4
+ data.tar.gz: ad1536d4cd5639e70d4f138a289f4fc59250c9d0
5
5
  SHA512:
6
- metadata.gz: b3d70e7a309c7124bb47b1ccfec371673dcfe89741df7d7a1f029e95b97381833bf5bf6239b23bc0c4d6dabf455e53356c37bf7b63ac0b3ebca21ad4708a6333
7
- data.tar.gz: b06644348ba495de742978219e1ac1f41d044a692b0df7aaba47b42892151fd2847fbcc07f3c6355f2998753c6f601bf5292c93efa9bcd2ea3a4f1ee8307f2c5
6
+ metadata.gz: 125cd1fa26f50f6e6e8c1c162f6357177015a4fe3c340d6e95e1dc1295ef27f9dea83c280d8e52fb865214243427bdf2ec8479bd6f53edbcb54f1ced2b525b2a
7
+ data.tar.gz: ad32aa74c0b5005f039ea864ae8db43316e43a4e58c86bab7ba05baf509e63e121eb36924e96e74548b8704a44fa7fe057dc128b3331b542075e1cb58cfbb207
@@ -14,21 +14,25 @@ module TcoClientCore
14
14
  end
15
15
  end
16
16
 
17
+ def to_json
18
+ to_s
19
+ end
20
+
17
21
  def as_json
18
22
  JSON.parse(raw)
19
23
  end
20
24
 
21
25
  def to_s
22
- raw
26
+ raw.to_s
23
27
  end
24
28
 
25
29
  def to_struct(object=nil)
26
30
  object ||= as_json
27
31
  if object.is_a? Array
28
- object.map { |v| to_struct(v) }
32
+ object.map { |v| v.nil? ? v : to_struct(v) }
29
33
  elsif object.is_a? Hash
30
34
  object.each_with_object(OpenStruct.new) do |(key, val), st|
31
- st[key] = to_struct(val)
35
+ st[key] = val.nil? ? val : to_struct(val)
32
36
  end
33
37
  else
34
38
  object
@@ -1,3 +1,3 @@
1
1
  module TcoClientCore
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -15,6 +15,12 @@ describe TcoClientCore::Response do
15
15
  end
16
16
 
17
17
  describe "#to_json" do
18
+ it "returns the raw json" do
19
+ expect(subject.to_json).to eq(raw_response)
20
+ end
21
+ end
22
+
23
+ describe "#as_json" do
18
24
  it "returns the response as json" do
19
25
  expect(subject.as_json).to have_key("test")
20
26
  end
@@ -43,6 +49,14 @@ describe TcoClientCore::Response do
43
49
  })
44
50
  expect(ostruct.two.three.first).to be_kind_of(OpenStruct)
45
51
  end
52
+
53
+ context "with nil values" do
54
+ subject { TcoClientCore::Response.new({ test: nil }.to_json) }
55
+
56
+ it "does not create an infinite loop" do
57
+ expect { subject.to_struct }.not_to raise_error
58
+ end
59
+ end
46
60
  end
47
61
 
48
62
  context "with an array" do
@@ -59,6 +73,14 @@ describe TcoClientCore::Response do
59
73
  ])
60
74
  expect(array.last.first).to be_kind_of(OpenStruct)
61
75
  end
76
+
77
+ context "with nil values" do
78
+ subject { TcoClientCore::Response.new([nil].to_json) }
79
+
80
+ it "does not create an infinite loop" do
81
+ expect { subject.to_struct }.not_to raise_error
82
+ end
83
+ end
62
84
  end
63
85
  end
64
86
 
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require "rubygems"
2
2
  require "awesome_print"
3
3
  require "bundler/setup"
4
4
  require "tco_client_core"
5
- require "vcr"
6
5
  require "json"
7
6
 
8
7
  RSpec.configure do |config|
@@ -12,11 +11,4 @@ end
12
11
 
13
12
  TcoClientCore.configure do |config|
14
13
  config.base_uri = "localhost:4000/internal"
15
- end
16
-
17
- VCR.configure do |config|
18
- config.configure_rspec_metadata!
19
- config.allow_http_connections_when_no_cassette = true
20
- config.cassette_library_dir = "spec/fixtures/vcr_cassettes"
21
- config.hook_into :webmock
22
- end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tco_client_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2CO Inc
@@ -220,34 +220,6 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '3.2'
223
- - !ruby/object:Gem::Dependency
224
- name: vcr
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '2.9'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - "~>"
235
- - !ruby/object:Gem::Version
236
- version: '2.9'
237
- - !ruby/object:Gem::Dependency
238
- name: webmock
239
- requirement: !ruby/object:Gem::Requirement
240
- requirements:
241
- - - "~>"
242
- - !ruby/object:Gem::Version
243
- version: '1.20'
244
- type: :development
245
- prerelease: false
246
- version_requirements: !ruby/object:Gem::Requirement
247
- requirements:
248
- - - "~>"
249
- - !ruby/object:Gem::Version
250
- version: '1.20'
251
223
  description: Handles communication with 2checkout.com's API
252
224
  email:
253
225
  - support@2co.com