daily_affirmation 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/daily_affirmation/affirmations.rb +7 -1
- data/lib/daily_affirmation/version.rb +1 -1
- data/spec/daily_affirmation_spec.rb +16 -0
- 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: 305ab950efd80d14e92eff86fd045a339a22aa8b
|
4
|
+
data.tar.gz: 9afae48904dc91d603ce35cd7a261be311089eb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40902db7caf7ddc098d8e2515637bcde4f1a3a47e1c2e854728c80776d85761917803dbf4023cc342d0bc59a8bc2761ce90c0d7b70b690a7eeea8f1eb449dcff
|
7
|
+
data.tar.gz: 76486bf174bdaca77ba75b66e5a676b32aa7d9b24c77b839f4de11d5ade12042edd875cc1e5ea486aec5cb3a3088024bae4176f069e1b305c3e90e606ddf4289
|
@@ -47,7 +47,13 @@ module DailyAffirmation
|
|
47
47
|
validator = Object.const_get(
|
48
48
|
"DailyAffirmation::Validators::#{type.to_s.capitalize}Validator"
|
49
49
|
)
|
50
|
-
validator.new(object, attribute, args).affirm
|
50
|
+
results = validator.new(object, attribute, args).affirm
|
51
|
+
|
52
|
+
if args.fetch(:inverse, false)
|
53
|
+
[!results[0], results[1]]
|
54
|
+
else
|
55
|
+
results
|
56
|
+
end
|
51
57
|
else
|
52
58
|
[true, nil]
|
53
59
|
end
|
@@ -130,4 +130,20 @@ describe DailyAffirmation do
|
|
130
130
|
expect(affirmation1).to be_valid
|
131
131
|
expect(affirmation2).to_not be_valid
|
132
132
|
end
|
133
|
+
|
134
|
+
it "allows each affirmation to be inverted via an :inverse option" do
|
135
|
+
cls = Class.new do
|
136
|
+
include DailyAffirmation.affirmations
|
137
|
+
|
138
|
+
affirms_presence_of :name, :inverse => true
|
139
|
+
end
|
140
|
+
|
141
|
+
obj1 = double(:name => nil)
|
142
|
+
obj2 = double(:name => :foo)
|
143
|
+
|
144
|
+
affirmation1 = cls.new(obj1)
|
145
|
+
affirmation2 = cls.new(obj2)
|
146
|
+
expect(affirmation1).to be_valid
|
147
|
+
expect(affirmation2).to_not be_valid
|
148
|
+
end
|
133
149
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily_affirmation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|