strong_json 0.5.0 → 0.6.0

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: e9d483b7a44d8b5dff5e7fa548376551d458a6e6
4
- data.tar.gz: c1156e637dfc48a712dcfa2ccf71864f18918535
3
+ metadata.gz: a5ae6973c112d772bdc495d5d50d5148f767bc71
4
+ data.tar.gz: 9c08bcd7842863cd40b727bf05007fec4be82f23
5
5
  SHA512:
6
- metadata.gz: 615fc0454b7898ea953a67c92386676d4d599a98569e093ffae4350140d733f69a0da0c79cb5fe0c7bf99ec5ad378a004929adbe942e7784fc2a31ea5dcb9fa1
7
- data.tar.gz: 3ca93c4ff958334fdd35cf8372c2b1c05a9e8031749df0188a1c612f83b32b15991a5d419038977ecb3269861628a760ca69c1a18ff8f37c62ccee93783174a3
6
+ metadata.gz: 6da4d4154502cc0bc422b1b5b1ff22c2033972d5cda06cdaeee3241c5d4eaa511151f622a6297e00dbaad632e20591fe67e1b9415cf755bd44ff83f9c77f5cc7
7
+ data.tar.gz: 50668c460b0ac655c48b6a93b4fd1e8c631474e1b70ab3c2850a4bf54e0ac92419a618d708e36fe3ab420f0189f3a61bd1e009019a4ccc51703bf989d02c8e63
@@ -167,7 +167,7 @@ class StrongJSON
167
167
 
168
168
  def merge(fields)
169
169
  if fields.is_a?(Object)
170
- fields = Object.instance_variable_get("@fields")
170
+ fields = fields.instance_variable_get("@fields")
171
171
  end
172
172
 
173
173
  Object.new(@fields.merge(fields))
@@ -1,3 +1,3 @@
1
1
  class StrongJSON
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -65,6 +65,18 @@ describe StrongJSON::Type::Object do
65
65
 
66
66
  expect{ ty2.coerce(a: 123) }.to raise_error(StrongJSON::Type::Error)
67
67
  end
68
+
69
+ it "adds field via object" do
70
+ ty2 = type.merge(StrongJSON::Type::Object.new(b: StrongJSON::Type::Base.new(:string)))
71
+
72
+ expect(ty2.coerce(a: 123, b: "test")).to eq(a: 123, b: "test")
73
+ end
74
+
75
+ it "overrides field via object" do
76
+ ty2 = type.merge(StrongJSON::Type::Object.new(a: StrongJSON::Type::Base.new(:prohibited)))
77
+
78
+ expect{ ty2.coerce(a: 123) }.to raise_error(StrongJSON::Type::Error)
79
+ end
68
80
  end
69
81
 
70
82
  describe "#except" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strong_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler