blood_contracts-ext 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc166259db639924bac7b4d744370f02a5ca5d0a63ad5e599b1242be5c216975
4
- data.tar.gz: '081498f6fa798663d602740fc4c806c160c04349c31ab14e04efc49554555bd6'
3
+ metadata.gz: adc2791a150c859a69878b6976513d7e202323a9e3b0e37efedeffa106606738
4
+ data.tar.gz: edfdb0c72e7a3cbf963edc28dcf2b2d22d2b8bfbb2966c6320fd53aac568c84c
5
5
  SHA512:
6
- metadata.gz: e4924c1d8982a1c77c881c41a228324a30fcb3bd8a1169e5e6587631ead8d2c3b6a3908a34e35551f7508728836a318077f5eca4ff43ac9b18e6972008b0abd6
7
- data.tar.gz: b5c5d419ebdf872e1c14b0cc0b33d87a956f9b9ea3c95010e6e55e5a5a241b29d6853a7c31c480ffff89576825dd566953df6c9e0a5f5aa017461ce3846c8b7d
6
+ metadata.gz: da3209e6a3507387123f854dbd2e4cc5dcbf8060dd55280a201a0bbb1d0d891c86700773c595c08c905e038457ead803033c722757e733c269f302426dd402da
7
+ data.tar.gz: 249e933564ece72db4ebd222963df65a27a9416918233cb831516f4ef6f6949be1af11b5400ec4261f251281ea420bc0561ffed0360162a515369195a853c1be
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ 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.4] - [2018-08-30]
9
+
10
+ ### Fixes
11
+ Fix support of blood_contracts-core v0.4.4
12
+ The context is now duplicated for each validation in Sum or Tuple composition
13
+
8
14
  ## [0.1.3] - [2018-07-12]
9
15
 
10
16
  ### Fixes
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "blood_contracts-ext"
3
- gem.version = "0.1.3"
3
+ gem.version = "0.1.4"
4
4
  gem.authors = ["Sergey Dolganov (sclinede)"]
5
5
  gem.email = ["sclinede@evilmartians.com"]
6
6
 
@@ -1,6 +1,13 @@
1
1
  module BloodContracts::Core
2
2
  # Represents failure in Sum data matching
3
3
  class SumPolicyFailure < PolicyFailure
4
+ # Accessor to contexts of Ext::Sum failed matches
5
+ #
6
+ # @return [Array<Hash>]
7
+ def contexts
8
+ @context[:sum_failure_contexts]
9
+ end
10
+
4
11
  # Custom accessor for policy errors in case of Ext::Sum types composition
5
12
  def policy_errors
6
13
  @policy_errors ||= @context[:sum_errors].map(&:policy_errors).flatten
@@ -21,7 +21,7 @@ module BloodContracts::Core
21
21
  #
22
22
  def failure(*, **)
23
23
  @context[:sub_scope] = self.class.name
24
- @context[:attributes].store(:base, super)
24
+ super
25
25
  end
26
26
  end
27
27
  end
@@ -63,7 +63,6 @@ RSpec.describe BloodContracts::Core::PolicyFailure do
63
63
  let(:value) { "tasf" }
64
64
  let(:errors_list) do
65
65
  [
66
- { Test::Login => [kind_of(Tram::Policy::Errors)] },
67
66
  { Test::Email => [kind_of(Tram::Policy::Errors)] },
68
67
  { Test::Phone => [kind_of(Tram::Policy::Errors)] }
69
68
  ]
@@ -88,7 +87,7 @@ RSpec.describe BloodContracts::Core::PolicyFailure do
88
87
  expect(subject.errors).to match_array(errors_list)
89
88
  expect(subject.policy_errors).to match(policy_errors)
90
89
  expect(subject.messages).to match_array(messages)
91
- expect(subject.context).to include(validation_context)
90
+ expect(subject.contexts.reduce(:merge)).to include(validation_context)
92
91
  end
93
92
  end
94
93
  end
@@ -116,15 +115,12 @@ RSpec.describe BloodContracts::Core::PolicyFailure do
116
115
  let(:attribute_errors) do
117
116
  {
118
117
  login: kind_of(BC::PolicyFailure),
119
- base: kind_of(BC::TuplePolicyFailure)
120
118
  }
121
119
  end
122
120
  let(:errors) do
123
121
  [
124
122
  { Test::Email => [kind_of(Tram::Policy::Errors)] },
125
123
  { Test::Phone => [kind_of(Tram::Policy::Errors)] },
126
- { Test::Login => [kind_of(Tram::Policy::Errors)] },
127
- { Test::RegistrationInput => [kind_of(Tram::Policy::Errors)] }
128
124
  ]
129
125
  end
130
126
  let(:attribute_messages) do
@@ -133,14 +129,12 @@ RSpec.describe BloodContracts::Core::PolicyFailure do
133
129
  "Given value is not a valid email",
134
130
  "Value `admin` is not a valid phone"
135
131
  ],
136
- base: ["Data for registration is invalid"]
137
132
  }
138
133
  end
139
134
 
140
135
  it do
141
136
  expect(subject).to be_invalid
142
137
  expect(subject.attributes).to match(attributes)
143
- expect(subject.to_h).to match(hash_including(login: login_error))
144
138
  expect(subject.errors).to match_array(errors)
145
139
  expect(subject.attribute_errors).to match(attribute_errors)
146
140
  expect(subject.attribute_messages).to match(attribute_messages)
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.3
4
+ version: 0.1.4
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-08-12 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blood_contracts-core