cooperator 0.1.0 → 0.1.1
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/lib/cooperator/context.rb +4 -4
- data/lib/cooperator/version.rb +1 -1
- data/spec/context.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c4488b6b7b963727bdc7fd71b29fed2a6a689df
|
4
|
+
data.tar.gz: ba79736c55a012ae4c9e388cf686615a3d5d2de8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6955b1fcd5dd16d7a52b5ceb5533188c597e1753a3c0390a2f63a7b1cff94776d41fd567488614fa60e69ee201e34fcbb3eb6025aa5c13412f827a37b690c24d
|
7
|
+
data.tar.gz: 8795e69ff4dda864bb1af0adbad1b91efeb058b1fb56c6e0b4c28f6123a44dc11d9777507b682afc06e557409b4eec3cef22131edbdc4aad85774894ed949466
|
data/lib/cooperator/context.rb
CHANGED
@@ -9,16 +9,16 @@ module Cooperator
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def errors
|
12
|
-
@_errors ||= []
|
12
|
+
@_errors ||= Hash.new { |h, k| h[k] = [] }
|
13
13
|
end
|
14
14
|
|
15
15
|
def success!
|
16
16
|
self._failure = false
|
17
17
|
end
|
18
18
|
|
19
|
-
def failure!(
|
20
|
-
|
21
|
-
errors.push
|
19
|
+
def failure!(messages = {})
|
20
|
+
messages.each do |key, message|
|
21
|
+
errors[key].push message
|
22
22
|
end
|
23
23
|
|
24
24
|
self._failure = true
|
data/lib/cooperator/version.rb
CHANGED
data/spec/context.rb
CHANGED
@@ -15,10 +15,10 @@ spec '.new accepts a hash' do
|
|
15
15
|
assert context.name, :==, 'Apple'
|
16
16
|
end
|
17
17
|
|
18
|
-
spec '#errors is
|
18
|
+
spec '#errors is a hash of error messages' do
|
19
19
|
context = Cooperator::Context.new
|
20
20
|
|
21
|
-
assert context.errors, :is_a?,
|
21
|
+
assert context.errors, :is_a?, Hash
|
22
22
|
end
|
23
23
|
|
24
24
|
spec '#success! marks the context as a success' do
|
@@ -37,11 +37,11 @@ spec '#failure! marks the context as a failure' do
|
|
37
37
|
refute context, :success?
|
38
38
|
end
|
39
39
|
|
40
|
-
spec '#failure! accepts an error message' do
|
40
|
+
spec '#failure! accepts an error key and message' do
|
41
41
|
context = Cooperator::Context.new
|
42
|
-
context.failure! 'Failure!'
|
42
|
+
context.failure! action: 'Failure!'
|
43
43
|
|
44
|
-
assert context.errors, :
|
44
|
+
assert context.errors, :==, action: ['Failure!']
|
45
45
|
end
|
46
46
|
|
47
47
|
spec '#include? returns true for an existing attribute' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cooperator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erol Fornoles
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.2.
|
82
|
+
rubygems_version: 2.2.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Simple cooperative interactors for Ruby
|