much-result 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +9 -0
- data/lib/much-result.rb +10 -1
- data/lib/much-result/version.rb +1 -1
- data/test/unit/much-result_tests.rb +28 -1
- 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: 2114bc845c36c3d435c0c3fa6fb6015e75aed0d4a8247aa1c60e15010562dbae
|
4
|
+
data.tar.gz: 7624db2f9dbc4dc974132f45d10a74c0bca005216a3e0de7ae33f89e8c6a3974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a5f2dab0534c563be0620fa2f5c8b1bf4743490e533e57ccf048ed965f4e0f8b9b7781037c9c5168278ede24f2ed89311275f65c607c3db1877af416b378bf
|
7
|
+
data.tar.gz: f4e01c6d702d88800ecab7e26f715535795675e6582c948f601bd02311bea474f5d4e112e2a4b243aade0c33c13554ac1461fada2b4cfebfc985f5bb22afd275
|
data/README.md
CHANGED
@@ -59,6 +59,15 @@ result.set(
|
|
59
59
|
result.message # => "it worked!"
|
60
60
|
result.other_value1 # => "something else 1"
|
61
61
|
result.other_value2 # => "something else 2"
|
62
|
+
|
63
|
+
result.attribute_names # => [:message, :other_value1, :other_value2]
|
64
|
+
|
65
|
+
result.attributes
|
66
|
+
# => {
|
67
|
+
# message: "it worked!",
|
68
|
+
# other_value1: "something else 1",
|
69
|
+
# other_value2: "something else 2"
|
70
|
+
# }
|
62
71
|
```
|
63
72
|
|
64
73
|
### Capture sub-Results
|
data/lib/much-result.rb
CHANGED
@@ -77,6 +77,14 @@ class MuchResult
|
|
77
77
|
self
|
78
78
|
end
|
79
79
|
|
80
|
+
def attributes
|
81
|
+
@data.to_h.reject { |key, _| key.to_s.start_with?("much_result_") }
|
82
|
+
end
|
83
|
+
|
84
|
+
def attribute_names
|
85
|
+
attributes.keys
|
86
|
+
end
|
87
|
+
|
80
88
|
def success?
|
81
89
|
if @success_predicate.nil?
|
82
90
|
@success_predicate =
|
@@ -197,7 +205,8 @@ class MuchResult
|
|
197
205
|
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} "\
|
198
206
|
"#{success? ? "SUCCESS" : "FAILURE"} "\
|
199
207
|
"#{"@description=#{@description.inspect} " if @description}"\
|
200
|
-
"@sub_results=#{@sub_results.inspect}
|
208
|
+
"@sub_results=#{@sub_results.inspect} "\
|
209
|
+
"attribute_names: #{attribute_names}>"
|
201
210
|
end
|
202
211
|
|
203
212
|
private
|
data/lib/much-result/version.rb
CHANGED
@@ -157,6 +157,7 @@ class MuchResult
|
|
157
157
|
}
|
158
158
|
|
159
159
|
should have_imeths :description, :backtrace, :set
|
160
|
+
should have_imeths :attributes, :attribute_names
|
160
161
|
should have_imeths :success?, :failure?
|
161
162
|
should have_imeths :capture_for, :capture_for!
|
162
163
|
should have_imeths :capture_for_all, :capture_for_all!
|
@@ -194,15 +195,41 @@ class MuchResult
|
|
194
195
|
assert_that(exception.backtrace).equals(backtrace1)
|
195
196
|
end
|
196
197
|
|
197
|
-
should "allow setting arbitrary
|
198
|
+
should "allow setting arbitrary attributes" do
|
199
|
+
assert_that(subject.attributes).is_empty
|
200
|
+
assert_that(subject.attribute_names).is_empty
|
201
|
+
|
202
|
+
new_value = Factory.string
|
203
|
+
subject.new_attribute = new_value
|
204
|
+
|
205
|
+
assert_that(subject.attributes).equals(new_attribute: new_value)
|
206
|
+
assert_that(subject.attribute_names).equals([:new_attribute])
|
207
|
+
|
208
|
+
assert_that(subject.other_value).is_nil
|
209
|
+
assert_that(subject.attributes).equals(new_attribute: new_value)
|
210
|
+
assert_that(subject.attribute_names).equals([:new_attribute])
|
211
|
+
|
212
|
+
return_value = subject.set(other_value: nil)
|
213
|
+
|
214
|
+
assert_that(return_value).is_the_same_as(subject)
|
198
215
|
assert_that(subject.other_value).is_nil
|
216
|
+
assert_that(subject.attributes)
|
217
|
+
.equals(new_attribute: new_value, other_value: nil)
|
218
|
+
assert_that(subject.attribute_names)
|
219
|
+
.equals([:new_attribute, :other_value])
|
199
220
|
|
200
221
|
subject.set(other_value: value1)
|
222
|
+
|
201
223
|
assert_that(subject.other_value).equals(value1)
|
224
|
+
assert_that(subject.attributes)
|
225
|
+
.equals(new_attribute: new_value, other_value: value1)
|
226
|
+
assert_that(subject.attribute_names)
|
227
|
+
.equals([:new_attribute, :other_value])
|
202
228
|
end
|
203
229
|
|
204
230
|
should "capture MuchResults as sub-results" do
|
205
231
|
subject.capture_for(unit_class.success(values: { value1: Factory.value }))
|
232
|
+
|
206
233
|
assert_that(subject.success?).is_true
|
207
234
|
assert_that(subject.sub_results.size).equals(1)
|
208
235
|
assert_that(subject.success_sub_results.size).equals(1)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: much-result
|
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
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: assert
|