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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de7cde41f8ed2a4d5af74de5c1229c8d7fbf4c2a4b0f3a42986861fbedc8990a
4
- data.tar.gz: 724c7604e77f776b91ecea0755b1665538a7336a1098059649bbf3fde3fd21a3
3
+ metadata.gz: fc166259db639924bac7b4d744370f02a5ca5d0a63ad5e599b1242be5c216975
4
+ data.tar.gz: '081498f6fa798663d602740fc4c806c160c04349c31ab14e04efc49554555bd6'
5
5
  SHA512:
6
- metadata.gz: 751cc11b82bfb8c3486f8360541f3663c7bcc7d8a3960f93c59b51b98131c4818ff728f72b738a45745272784bbe1583a223c27ad47c1ac4633ab225fe8a7582
7
- data.tar.gz: 15f7dbcd27561aca9f52e7e9bfa80020cdc84204441b580e7612d0176c0e9dba541da6cf20bb9c9e23a9a1df68660f61f827d68f675ee36591f3af598caf4b2d
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:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "blood_contracts-ext"
3
- gem.version = "0.1.2"
3
+ gem.version = "0.1.3"
4
4
  gem.authors = ["Sergey Dolganov (sclinede)"]
5
5
  gem.email = ["sclinede@evilmartians.com"]
6
6
 
@@ -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
- @context[:parsed] ||= JSON.parse(value)
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.2
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-07-18 00:00:00.000000000 Z
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