contracted_value 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/coverage.yml +3 -3
- data/.github/workflows/tests.yaml +2 -5
- data/Appraisals +2 -2
- data/CHANGELOG.md +12 -2
- data/README.md +1 -1
- data/contracted_value.gemspec +5 -5
- data/lib/contracted_value/core.rb +17 -8
- data/lib/contracted_value/version.rb +1 -1
- data/spec/contracted_value/value_spec.rb +145 -169
- metadata +15 -10
- data/gemfiles/contracts_16_0.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1955c7fa4eaf8ae64db37e57575a6da241315ebd5855d72097e8e175292d0ee3
|
4
|
+
data.tar.gz: d34b3b78b78e7e27466468851e96968293e978cadfc40104e3a67425e69eb4a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125f0ff78bdf35d47b2fd7400ebb93db3a249d0b04abe1462394b732ad1d804326d7d89c7b04e0d3ca28cb738bc1f350a5091d2ae559490cfea468b864a1d03d
|
7
|
+
data.tar.gz: 184cd1009cbd96af31d5fce7c075c483ce4762fc77936843c66a13df2c43b0aa95e70fe14e5e7c8ddaea1ebaf6a85084fc0345479af1e2a273cab6ca8942f64d
|
@@ -24,16 +24,16 @@ jobs:
|
|
24
24
|
os:
|
25
25
|
- ubuntu-latest
|
26
26
|
ruby:
|
27
|
-
- "2
|
27
|
+
- "3.2"
|
28
28
|
gemfile:
|
29
|
-
- gemfiles/
|
29
|
+
- gemfiles/contracts_17_0.gemfile
|
30
30
|
env:
|
31
31
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
32
32
|
COVERALLS: true
|
33
33
|
runs-on: ${{ matrix.os }}
|
34
34
|
steps:
|
35
35
|
- name: Checkout
|
36
|
-
uses: actions/checkout@
|
36
|
+
uses: actions/checkout@v4
|
37
37
|
|
38
38
|
- name: Setup Ruby
|
39
39
|
uses: ruby/setup-ruby@v1
|
@@ -26,15 +26,12 @@ jobs:
|
|
26
26
|
ruby:
|
27
27
|
- "3.0"
|
28
28
|
- "3.1"
|
29
|
+
- "3.2"
|
29
30
|
gemfile:
|
30
31
|
- gemfiles/contracts_17_0.gemfile
|
31
32
|
allow_failures:
|
32
33
|
- false
|
33
34
|
include:
|
34
|
-
- os: ubuntu-latest
|
35
|
-
ruby: "2.7"
|
36
|
-
gemfile: gemfiles/contracts_16_0.gemfile
|
37
|
-
allow_failures: false
|
38
35
|
- os: ubuntu-latest
|
39
36
|
ruby: "ruby-head"
|
40
37
|
gemfile: gemfiles/contracts_17_0.gemfile
|
@@ -46,7 +43,7 @@ jobs:
|
|
46
43
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
47
44
|
steps:
|
48
45
|
- name: Checkout
|
49
|
-
uses: actions/checkout@
|
46
|
+
uses: actions/checkout@v4
|
50
47
|
- name: Setup Ruby
|
51
48
|
uses: ruby/setup-ruby@v1
|
52
49
|
with:
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -18,7 +18,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
18
18
|
- Nothing
|
19
19
|
|
20
20
|
|
21
|
-
## [
|
21
|
+
## [0.1.2]
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Requires Ruby 3.0, contracts >= 0.17 (Ruby 2.7 EOL)
|
26
|
+
- Make code "Object Shape friendly"
|
27
|
+
(https://github.com/PikachuEXE/contracted_value/pull/5)
|
28
|
+
|
29
|
+
|
30
|
+
## [0.1.1]
|
22
31
|
|
23
32
|
### Changed
|
24
33
|
|
@@ -35,4 +44,5 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
35
44
|
|
36
45
|
- Initial release
|
37
46
|
|
38
|
-
[
|
47
|
+
[0.1.2]: https://github.com/PikachuEXE/contracted_value/compare/v0.1.1...v0.1.2
|
48
|
+
[0.1.1]: https://github.com/PikachuEXE/contracted_value/compare/v0.1.0...v0.1.1
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ See details explanation in below sections
|
|
11
11
|
|
12
12
|
## Status
|
13
13
|
|
14
|
-
[![GitHub Build Status](https://img.shields.io/github/workflow/status/PikachuEXE/contracted_value/
|
14
|
+
[![GitHub Build Status](https://img.shields.io/github/actions/workflow/status/PikachuEXE/contracted_value/tests.yaml?branch=master&style=flat-square)](https://github.com/PikachuEXE/contracted_value/actions/workflows/tests.yaml)
|
15
15
|
|
16
16
|
[![Gem Version](http://img.shields.io/gem/v/contracted_value.svg?style=flat-square)](http://badge.fury.io/rb/contracted_value)
|
17
17
|
[![License](https://img.shields.io/github/license/PikachuEXE/contracted_value.svg?style=flat-square)](http://badge.fury.io/rb/contracted_value)
|
data/contracted_value.gemspec
CHANGED
@@ -12,9 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
s.name = gem_name
|
14
14
|
s.version = ContractedValue::VERSION
|
15
|
-
s.summary = "
|
15
|
+
s.summary = "Contracted immutable(by default) value objects"
|
16
16
|
s.description = <<-DOC
|
17
|
-
|
17
|
+
Library for creating contracted immutable(by default) value objects supported by contracts.ruby & ice_nine
|
18
18
|
DOC
|
19
19
|
|
20
20
|
s.license = "MIT"
|
@@ -28,14 +28,14 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
29
29
|
s.require_paths = ["lib"]
|
30
30
|
|
31
|
-
s.add_dependency "contracts", "~> 0.
|
31
|
+
s.add_dependency "contracts", "~> 0.17"
|
32
32
|
s.add_dependency "ice_nine"
|
33
33
|
|
34
34
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
35
35
|
s.add_development_dependency "rake", ">= 10.0", "<= 14.0"
|
36
36
|
s.add_development_dependency "pry"
|
37
37
|
|
38
|
-
s.add_development_dependency "appraisal", "~> 2.0"
|
38
|
+
s.add_development_dependency "appraisal", "~> 2.0", ">= 2.5.0"
|
39
39
|
|
40
40
|
s.add_development_dependency "rspec", "~> 3.0"
|
41
41
|
s.add_development_dependency "rspec-its", "~> 1.0"
|
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
|
50
50
|
s.add_development_dependency "rubocop", ">= 0.70"
|
51
51
|
|
52
|
-
s.required_ruby_version = ">=
|
52
|
+
s.required_ruby_version = ">= 3.0.0"
|
53
53
|
|
54
54
|
s.required_rubygems_version = ">= 1.4.0"
|
55
55
|
end
|
@@ -182,10 +182,17 @@ module ContractedValue
|
|
182
182
|
attr_reader :default_value
|
183
183
|
|
184
184
|
def raise_error_if_inputs_invalid
|
185
|
+
raise_error_if_name_invalid
|
185
186
|
raise_error_if_refrigeration_mode_invalid
|
186
187
|
raise_error_if_default_value_invalid
|
187
188
|
end
|
188
189
|
|
190
|
+
def raise_error_if_name_invalid
|
191
|
+
return if name.is_a?(Symbol)
|
192
|
+
|
193
|
+
raise NotImplementedError, "Internal error: name is not a symbol (#{name.class.name})"
|
194
|
+
end
|
195
|
+
|
189
196
|
def raise_error_if_refrigeration_mode_invalid
|
190
197
|
return if RefrigerationMode::Enum.all.include?(refrigeration_mode)
|
191
198
|
|
@@ -231,6 +238,8 @@ module ContractedValue
|
|
231
238
|
)
|
232
239
|
end
|
233
240
|
|
241
|
+
@attr_values = {}
|
242
|
+
|
234
243
|
self.class.send(:attribute_set).each_attribute do |attribute|
|
235
244
|
attr_value = attribute.extract_value(input_attr_values_hash)
|
236
245
|
|
@@ -253,8 +262,8 @@ module ContractedValue
|
|
253
262
|
|
254
263
|
# Using symbol since attribute names are limited in number
|
255
264
|
# An alternative would be using frozen string
|
256
|
-
|
257
|
-
|
265
|
+
@attr_values.store(
|
266
|
+
attribute.name.to_sym,
|
258
267
|
sometimes_frozen_attr_value,
|
259
268
|
)
|
260
269
|
end
|
@@ -265,10 +274,7 @@ module ContractedValue
|
|
265
274
|
# rubocop:enable Metrics/CyclomaticComplexity
|
266
275
|
|
267
276
|
def to_h
|
268
|
-
|
269
|
-
each_attribute.each_with_object({}) do |attribute, hash|
|
270
|
-
hash[attribute.name] = instance_variable_get(:"@#{attribute.name}")
|
271
|
-
end
|
277
|
+
@attr_values.clone
|
272
278
|
end
|
273
279
|
|
274
280
|
# == Class interface == #
|
@@ -288,16 +294,19 @@ module ContractedValue
|
|
288
294
|
refrigeration_mode: RefrigerationMode::Enum::DEEP,
|
289
295
|
default_value: Private::ATTR_DEFAULT_VALUE_ABSENT_VAL
|
290
296
|
)
|
297
|
+
# Using symbol since attribute names are limited in number
|
298
|
+
# An alternative would be using frozen string
|
299
|
+
name_in_sym = name.to_sym
|
291
300
|
|
292
301
|
attr = Attribute.new(
|
293
|
-
name:
|
302
|
+
name: name_in_sym,
|
294
303
|
contract: contract,
|
295
304
|
refrigeration_mode: refrigeration_mode,
|
296
305
|
default_value: default_value,
|
297
306
|
)
|
298
307
|
@attribute_set = @attribute_set.add(attr)
|
299
308
|
|
300
|
-
|
309
|
+
define_method(name_in_sym) { @attr_values[name_in_sym] }
|
301
310
|
end
|
302
311
|
|
303
312
|
# @api private
|
@@ -10,40 +10,50 @@ require "spec_helper"
|
|
10
10
|
end
|
11
11
|
|
12
12
|
example "does not raise error when NOT declaring any attribute" do
|
13
|
-
expect
|
13
|
+
expect { value_class }.to_not raise_error
|
14
14
|
end
|
15
15
|
|
16
16
|
example "does not raise error when declaring 1 attribute" do
|
17
|
-
expect
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
},
|
23
|
-
).to_not raise_error
|
17
|
+
expect {
|
18
|
+
value_class.class_eval do
|
19
|
+
attribute(:attribute_1)
|
20
|
+
end
|
21
|
+
}.to_not raise_error
|
24
22
|
end
|
25
23
|
|
26
24
|
example "does not raise error when declaring N attributes with different names" do
|
27
|
-
expect
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
},
|
34
|
-
).to_not raise_error
|
25
|
+
expect {
|
26
|
+
value_class.class_eval do
|
27
|
+
attribute(:attribute_1)
|
28
|
+
attribute(:attribute_2)
|
29
|
+
end
|
30
|
+
}.to_not raise_error
|
35
31
|
end
|
36
32
|
|
37
33
|
example "does raise error when declaring N attributes with the same name" do
|
38
|
-
expect
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
expect {
|
35
|
+
value_class.class_eval do
|
36
|
+
attribute(:attribute_1)
|
37
|
+
attribute(:attribute_2)
|
38
|
+
attribute(:attribute_1)
|
39
|
+
end
|
40
|
+
}.to raise_error(::ContractedValue::Errors::DuplicateAttributeDeclaration)
|
41
|
+
end
|
42
|
+
|
43
|
+
example "does not raise error when declaring 1 attribute with string name" do
|
44
|
+
expect {
|
45
|
+
value_class.class_eval do
|
46
|
+
attribute("attribute_1")
|
47
|
+
end
|
48
|
+
}.to_not raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
example "does not raise error when declaring 1 attribute with number name" do
|
52
|
+
expect {
|
53
|
+
value_class.class_eval do
|
54
|
+
attribute(1)
|
55
|
+
end
|
56
|
+
}.to raise_error(::NoMethodError, /undefined method `to_sym'/)
|
47
57
|
end
|
48
58
|
end
|
49
59
|
|
@@ -79,39 +89,39 @@ require "spec_helper"
|
|
79
89
|
|
80
90
|
it "does raise error when input is not a hash" do
|
81
91
|
aggregate_failures do
|
82
|
-
expect
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
},
|
88
|
-
).to raise_error(::ContractedValue::Errors::InvalidInputType)
|
92
|
+
expect {
|
93
|
+
value_class.new(
|
94
|
+
non_hash,
|
95
|
+
)
|
96
|
+
}.to raise_error(::ContractedValue::Errors::InvalidInputType)
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
92
100
|
it "does not raise error when input is a hash" do
|
93
101
|
aggregate_failures do
|
94
|
-
expect
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
},
|
100
|
-
).to_not raise_error
|
102
|
+
expect {
|
103
|
+
value_class.new(
|
104
|
+
default_inputs,
|
105
|
+
)
|
106
|
+
}.to_not raise_error
|
101
107
|
end
|
102
108
|
end
|
103
109
|
|
104
110
|
it "does not raise error when input is a value" do
|
105
111
|
aggregate_failures do
|
106
|
-
|
107
|
-
|
112
|
+
new_val = nil
|
113
|
+
expect {
|
114
|
+
new_val = value_class.new(
|
108
115
|
value_class.new(
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
116
|
+
default_inputs,
|
117
|
+
),
|
118
|
+
)
|
119
|
+
}.to_not raise_error
|
120
|
+
if new_val
|
121
|
+
default_inputs.each_pair do |attr_name, attr_val|
|
122
|
+
expect(new_val.public_send(attr_name)).to eq(attr_val)
|
123
|
+
end
|
124
|
+
end
|
115
125
|
end
|
116
126
|
end
|
117
127
|
|
@@ -121,13 +131,11 @@ require "spec_helper"
|
|
121
131
|
:attribute_1,
|
122
132
|
:attribute_2,
|
123
133
|
].each do |attr_name|
|
124
|
-
expect
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
},
|
130
|
-
).to raise_error(::ContractedValue::Errors::MissingAttributeInput)
|
134
|
+
expect {
|
135
|
+
value_class.new(
|
136
|
+
default_inputs.dup.tap{|h| h.delete(attr_name)},
|
137
|
+
)
|
138
|
+
}.to raise_error(::ContractedValue::Errors::MissingAttributeInput)
|
131
139
|
end
|
132
140
|
end
|
133
141
|
end
|
@@ -138,15 +146,13 @@ require "spec_helper"
|
|
138
146
|
:attribute_1,
|
139
147
|
:attribute_2,
|
140
148
|
].each do |attr_name|
|
141
|
-
expect
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
},
|
149
|
-
).to_not raise_error
|
149
|
+
expect {
|
150
|
+
value_class.new(
|
151
|
+
default_inputs.each_with_object({}) do |(k, _v), h|
|
152
|
+
h[k] = nil
|
153
|
+
end
|
154
|
+
)
|
155
|
+
}.to_not raise_error
|
150
156
|
end
|
151
157
|
end
|
152
158
|
end
|
@@ -175,36 +181,30 @@ require "spec_helper"
|
|
175
181
|
|
176
182
|
|
177
183
|
it "does not raise error when all values are valid according to contracts" do
|
178
|
-
expect
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
},
|
184
|
-
).to_not raise_error
|
184
|
+
expect {
|
185
|
+
value_class.new(
|
186
|
+
default_inputs
|
187
|
+
)
|
188
|
+
}.to_not raise_error
|
185
189
|
end
|
186
190
|
|
187
191
|
it "does raise error when any value is invalid according to contracts" do
|
188
192
|
aggregate_failures do
|
189
|
-
expect
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
},
|
197
|
-
).to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
193
|
+
expect {
|
194
|
+
value_class.new(
|
195
|
+
default_inputs.merge(
|
196
|
+
attribute_with_contract_1: "",
|
197
|
+
),
|
198
|
+
)
|
199
|
+
}.to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
198
200
|
|
199
|
-
expect
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
},
|
207
|
-
).to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
201
|
+
expect {
|
202
|
+
value_class.new(
|
203
|
+
default_inputs.merge(
|
204
|
+
attribute_with_contract_2: 0,
|
205
|
+
),
|
206
|
+
)
|
207
|
+
}.to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
end
|
@@ -237,22 +237,18 @@ require "spec_helper"
|
|
237
237
|
# Create it just before expectation
|
238
238
|
value_object
|
239
239
|
|
240
|
-
expect
|
241
|
-
|
242
|
-
|
243
|
-
},
|
244
|
-
).to raise_error(::RuntimeError, /can't modify frozen/)
|
240
|
+
expect {
|
241
|
+
hash_as_input[:a] = nil
|
242
|
+
}.to raise_error(::RuntimeError, /can't modify frozen/)
|
245
243
|
end
|
246
244
|
|
247
245
|
it "does deeply freeze the inputs" do
|
248
246
|
# Create it just before expectation
|
249
247
|
value_object
|
250
248
|
|
251
|
-
expect
|
252
|
-
|
253
|
-
|
254
|
-
},
|
255
|
-
).to raise_error(::RuntimeError, /can't modify frozen/)
|
249
|
+
expect {
|
250
|
+
hash_as_deep_nested_content[:a] = nil
|
251
|
+
}.to raise_error(::RuntimeError, /can't modify frozen/)
|
256
252
|
end
|
257
253
|
end
|
258
254
|
|
@@ -265,22 +261,18 @@ require "spec_helper"
|
|
265
261
|
# Create it just before expectation
|
266
262
|
value_object
|
267
263
|
|
268
|
-
expect
|
269
|
-
|
270
|
-
|
271
|
-
},
|
272
|
-
).to raise_error(::RuntimeError, /can't modify frozen/)
|
264
|
+
expect {
|
265
|
+
hash_as_input[:a] = nil
|
266
|
+
}.to raise_error(::RuntimeError, /can't modify frozen/)
|
273
267
|
end
|
274
268
|
|
275
269
|
it "does not deeply freeze the inputs" do
|
276
270
|
# Create it just before expectation
|
277
271
|
value_object
|
278
272
|
|
279
|
-
expect
|
280
|
-
|
281
|
-
|
282
|
-
},
|
283
|
-
).to_not raise_error
|
273
|
+
expect {
|
274
|
+
hash_as_deep_nested_content[:a] = nil
|
275
|
+
}.to_not raise_error
|
284
276
|
end
|
285
277
|
end
|
286
278
|
|
@@ -293,22 +285,18 @@ require "spec_helper"
|
|
293
285
|
# Create it just before expectation
|
294
286
|
value_object
|
295
287
|
|
296
|
-
expect
|
297
|
-
|
298
|
-
|
299
|
-
},
|
300
|
-
).to_not raise_error
|
288
|
+
expect {
|
289
|
+
hash_as_input[:a] = nil
|
290
|
+
}.to_not raise_error
|
301
291
|
end
|
302
292
|
|
303
293
|
it "does not deeply freeze the inputs" do
|
304
294
|
# Create it just before expectation
|
305
295
|
value_object
|
306
296
|
|
307
|
-
expect
|
308
|
-
|
309
|
-
|
310
|
-
},
|
311
|
-
).to_not raise_error
|
297
|
+
expect {
|
298
|
+
hash_as_deep_nested_content[:a] = nil
|
299
|
+
}.to_not raise_error
|
312
300
|
end
|
313
301
|
end
|
314
302
|
|
@@ -533,11 +521,9 @@ require "spec_helper"
|
|
533
521
|
end
|
534
522
|
|
535
523
|
example "does not raise error" do
|
536
|
-
expect
|
537
|
-
|
538
|
-
|
539
|
-
},
|
540
|
-
).to_not raise_error
|
524
|
+
expect {
|
525
|
+
child_value_class.new(attribute_1: "wut")
|
526
|
+
}.to_not raise_error
|
541
527
|
end
|
542
528
|
|
543
529
|
end
|
@@ -559,36 +545,30 @@ require "spec_helper"
|
|
559
545
|
end
|
560
546
|
|
561
547
|
example "does not raise error when declaring 1 new attribute" do
|
562
|
-
expect
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
},
|
568
|
-
).to_not raise_error
|
548
|
+
expect {
|
549
|
+
child_value_class.class_eval do
|
550
|
+
attribute(:attribute_3)
|
551
|
+
end
|
552
|
+
}.to_not raise_error
|
569
553
|
end
|
570
554
|
|
571
555
|
example "does not raise error when declaring N attributes with different names" do
|
572
|
-
expect
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
},
|
579
|
-
).to_not raise_error
|
556
|
+
expect {
|
557
|
+
child_value_class.class_eval do
|
558
|
+
attribute(:attribute_3)
|
559
|
+
attribute(:attribute_4)
|
560
|
+
end
|
561
|
+
}.to_not raise_error
|
580
562
|
end
|
581
563
|
|
582
564
|
example "does raise error when declaring N attributes with the same name" do
|
583
|
-
expect
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
},
|
591
|
-
).to raise_error(::ContractedValue::Errors::DuplicateAttributeDeclaration)
|
565
|
+
expect {
|
566
|
+
child_value_class.class_eval do
|
567
|
+
attribute(:attribute_3)
|
568
|
+
attribute(:attribute_4)
|
569
|
+
attribute(:attribute_3)
|
570
|
+
end
|
571
|
+
}.to raise_error(::ContractedValue::Errors::DuplicateAttributeDeclaration)
|
592
572
|
end
|
593
573
|
|
594
574
|
end
|
@@ -632,31 +612,27 @@ require "spec_helper"
|
|
632
612
|
end
|
633
613
|
|
634
614
|
example "does not raise error when declaring existing attribute with different contract" do
|
635
|
-
expect
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
},
|
645
|
-
).to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
615
|
+
expect {
|
616
|
+
child_value_class.class_eval do
|
617
|
+
attribute(
|
618
|
+
:attribute_1,
|
619
|
+
contract: ::Contracts::Builtin::NatPos
|
620
|
+
)
|
621
|
+
end
|
622
|
+
child_value_class.new(attribute_1: "")
|
623
|
+
}.to raise_error(::ContractedValue::Errors::InvalidAttributeValue)
|
646
624
|
end
|
647
625
|
|
648
626
|
example "does not raise error when declaring existing attribute with different default_value" do
|
649
|
-
expect
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
},
|
659
|
-
).to_not raise_error
|
627
|
+
expect {
|
628
|
+
child_value_class.class_eval do
|
629
|
+
attribute(
|
630
|
+
:attribute_1,
|
631
|
+
default_value: nil,
|
632
|
+
)
|
633
|
+
end
|
634
|
+
child_value_class.new
|
635
|
+
}.to_not raise_error
|
660
636
|
end
|
661
637
|
|
662
638
|
example "does not raise error when declaring existing attribute with different refrigeration_mode" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contracted_value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PikachuEXE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.17'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.17'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ice_nine
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +93,9 @@ dependencies:
|
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '2.0'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.5.0
|
96
99
|
type: :development
|
97
100
|
prerelease: false
|
98
101
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -100,6 +103,9 @@ dependencies:
|
|
100
103
|
- - "~>"
|
101
104
|
- !ruby/object:Gem::Version
|
102
105
|
version: '2.0'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 2.5.0
|
103
109
|
- !ruby/object:Gem::Dependency
|
104
110
|
name: rspec
|
105
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,8 +204,8 @@ dependencies:
|
|
198
204
|
- - ">="
|
199
205
|
- !ruby/object:Gem::Version
|
200
206
|
version: '0.70'
|
201
|
-
description: "
|
202
|
-
|
207
|
+
description: " Library for creating contracted immutable(by default) value objects
|
208
|
+
supported by contracts.ruby & ice_nine\n"
|
203
209
|
email:
|
204
210
|
- pikachuexe@gmail.com
|
205
211
|
executables: []
|
@@ -222,7 +228,6 @@ files:
|
|
222
228
|
- README.md
|
223
229
|
- Rakefile
|
224
230
|
- contracted_value.gemspec
|
225
|
-
- gemfiles/contracts_16_0.gemfile
|
226
231
|
- gemfiles/contracts_17_0.gemfile
|
227
232
|
- lib/contracted_value.rb
|
228
233
|
- lib/contracted_value/core.rb
|
@@ -242,17 +247,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
242
247
|
requirements:
|
243
248
|
- - ">="
|
244
249
|
- !ruby/object:Gem::Version
|
245
|
-
version:
|
250
|
+
version: 3.0.0
|
246
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
247
252
|
requirements:
|
248
253
|
- - ">="
|
249
254
|
- !ruby/object:Gem::Version
|
250
255
|
version: 1.4.0
|
251
256
|
requirements: []
|
252
|
-
rubygems_version: 3.
|
257
|
+
rubygems_version: 3.4.20
|
253
258
|
signing_key:
|
254
259
|
specification_version: 4
|
255
|
-
summary:
|
260
|
+
summary: Contracted immutable(by default) value objects
|
256
261
|
test_files:
|
257
262
|
- spec/contracted_value/value_spec.rb
|
258
263
|
- spec/contracted_value_spec.rb
|