hash_schema 0.1.0 → 0.1.1

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: 4a30a25b38f10cad859deefa8e318414c94055ab
4
- data.tar.gz: 4683b1715e4b134c3ea58bbf72bb711268b13e35
3
+ metadata.gz: 7788877ffd7c7aa507ade3fbb84cfbe58a2ad6e8
4
+ data.tar.gz: 2a2b2aa4fab62601f1cf5af5dd13676a383a1089
5
5
  SHA512:
6
- metadata.gz: 134fe97ce8908958baa7ca21b01990e5e50da4ff3d4c99fa9025cfd2228f639d045dcb453f2f0ff6c70ec1608433ba4f8c986467bbc445d41221c5081887359c
7
- data.tar.gz: d1c4aacaa841a7ce398becee5dc10a8cce192905a4eb84c82c23d5ce8258e0e0af5cd80827ddaf78943b04340b961d0ba8db1b96c6a903ba0d9f06d54524fe0f
6
+ metadata.gz: 1dd7c75d6b8f258d3d89d43cca6f1f1641ec3756b797d1b5c3ca01c3d44750ace31a329d2f616a1689b97f8baa85c3af1ca50b52ff7df090310cd2031ed5b19b
7
+ data.tar.gz: 202e68b5160accf317d017abc5185c1aa05dab9bd6c94281099f36693b98386081ed39ad7a7731d5c4f0926ccbae105116f761a748be5376a7d49e296a1c82ff
@@ -150,8 +150,8 @@ module HashSchema
150
150
  end
151
151
 
152
152
  class HashSchema < Schema
153
- def initialize(strict: false, **hash)
154
- @chain = hash
153
+ def initialize(strict: false, schema_hash: {}, **keywords)
154
+ @chain = schema_hash.merge(keywords)
155
155
  @strict = strict
156
156
  end
157
157
 
@@ -1,3 +1,3 @@
1
1
  module HashSchema
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -228,5 +228,15 @@ describe HashSchema do
228
228
  expect(schema.validate(data).reject { |_, v| v.nil? }).to include(:y)
229
229
  end
230
230
  end
231
+
232
+ context 'when hash keys contain "strict"' do
233
+ it 'works around by passing the whole hash as "schema_hash"' do
234
+ schema = subject.new(strict: true, schema_hash: { strict: HashSchema::NumberSchema.new })
235
+
236
+ data = { strict: 1 }
237
+
238
+ expect(schema.validate(data).reject { |_, v| v.nil? }).to be_empty
239
+ end
240
+ end
231
241
  end
232
242
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Po Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-02 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bump