blood_contracts-ext 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/blood_contracts-ext.gemspec +1 -1
- data/lib/blood_contracts/core/extractable.rb +1 -1
- data/spec/blood_contracts/ext/expected_error_spec.rb +27 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc166259db639924bac7b4d744370f02a5ca5d0a63ad5e599b1242be5c216975
|
4
|
+
data.tar.gz: '081498f6fa798663d602740fc4c806c160c04349c31ab14e04efc49554555bd6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4924c1d8982a1c77c881c41a228324a30fcb3bd8a1169e5e6587631ead8d2c3b6a3908a34e35551f7508728836a318077f5eca4ff43ac9b18e6972008b0abd6
|
7
|
+
data.tar.gz: b5c5d419ebdf872e1c14b0cc0b33d87a956f9b9ea3c95010e6e55e5a5a241b29d6853a7c31c480ffff89576825dd566953df6c9e0a5f5aa017461ce3846c8b7d
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## [0.1.3] - [2018-07-12]
|
9
|
+
|
10
|
+
### Fixes
|
11
|
+
Extractors should be copied during inheritance but children should not be able to modify the parents' @extractors.
|
12
|
+
|
13
|
+
## [0.1.2] - [2018-07-18]
|
14
|
+
|
15
|
+
### Fixes
|
16
|
+
Deep inheritance of BC::Ext::Refined was broken, fixed that
|
17
|
+
|
8
18
|
## [0.1.1] - [2018-07-10]
|
9
19
|
|
10
20
|
### Fixes:
|
data/blood_contracts-ext.gemspec
CHANGED
@@ -22,7 +22,7 @@ module BloodContracts::Core
|
|
22
22
|
# @private
|
23
23
|
def inherited(child)
|
24
24
|
super
|
25
|
-
child.instance_variable_set(:@extractors, extractors || {})
|
25
|
+
child.instance_variable_set(:@extractors, extractors.dup || {})
|
26
26
|
end
|
27
27
|
|
28
28
|
# DSL to define which method to use to extract data from the value
|
@@ -2,12 +2,31 @@ RSpec.describe BloodContracts::Core::ExpectedError do
|
|
2
2
|
before do
|
3
3
|
module Test
|
4
4
|
class PlainTextError < BC::ExpectedError
|
5
|
+
extract :plain_text
|
6
|
+
extract :parsed, method_name: :parse_json
|
7
|
+
|
5
8
|
def match
|
6
|
-
|
9
|
+
extract!
|
10
|
+
nil
|
7
11
|
rescue JSON::ParserError
|
8
|
-
@context[:plain_text] = value.to_s
|
9
12
|
self
|
10
13
|
end
|
14
|
+
|
15
|
+
def plain_text
|
16
|
+
value.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def parse_json
|
20
|
+
JSON.parse(value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class JustAnotherType < BC::ExpectedError
|
25
|
+
extract :thing
|
26
|
+
|
27
|
+
def thing
|
28
|
+
"THE THING"
|
29
|
+
end
|
11
30
|
end
|
12
31
|
|
13
32
|
class JsonType < BC::Ext::Refined
|
@@ -27,6 +46,12 @@ RSpec.describe BloodContracts::Core::ExpectedError do
|
|
27
46
|
|
28
47
|
subject { Test::Response.match(value) }
|
29
48
|
|
49
|
+
context "when several types have same parent" do
|
50
|
+
it do
|
51
|
+
expect(Test::JustAnotherType.extractors).to match(thing: [:thing])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
30
55
|
context "when value is a JSON" do
|
31
56
|
let(:value) { '{"name": "Andrew", "registered_at": "2019-01-01"}' }
|
32
57
|
let(:payload) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blood_contracts-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Dolganov (sclinede)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: blood_contracts-core
|