mongoid-minitest 0.1.2 → 0.1.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +4 -3
- data/lib/matchers/validations/validations.rb +25 -3
- data/lib/mongoid-minitest/version.rb +1 -1
- metadata +10 -9
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.1.3 - September 8, 2012
|
2
|
+
|
3
|
+
+ Bump mongoid version to 3.0.5 - *Francesco Rodriguez*.
|
4
|
+
+ Bump minitest version to 3.4.0 - *Francesco Rodriguez*.
|
5
|
+
+ Added on option for validation matchers.
|
6
|
+
Pull Request [#14](https://github.com/frodsan/mongoid-minitest/pull/14) - *Godfrey Chan*.
|
7
|
+
|
1
8
|
## 0.1.2 - August 13, 2012
|
2
9
|
|
3
10
|
+ Allow passing in a Regex to the validate_format_of matcher.
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ This gem supports:
|
|
10
10
|
|
11
11
|
* Ruby 1.9.3
|
12
12
|
* Mongoid ~>3.0.4
|
13
|
-
* MiniTest ~>3.
|
13
|
+
* MiniTest ~>3.4.0
|
14
14
|
|
15
15
|
If you're using Mongoid 2.4.x, you should use [0.0.3.1 version](https://github.com/frodsan/mongoid-minitest/tree/274976e8814cc9bfb3f1c83eba1bed21fa3cf26b).
|
16
16
|
|
@@ -181,8 +181,9 @@ To run unit tests, run `bundle exec rake`.
|
|
181
181
|
|
182
182
|
## Maintainers
|
183
183
|
|
184
|
-
* Francesco Rodriguez (
|
185
|
-
* Sascha Wessel (
|
184
|
+
* Francesco Rodriguez (https://github.com/frodsan/).
|
185
|
+
* Sascha Wessel (https://github.com/gr4y).
|
186
|
+
* Godfrey Chan (https://github.com/chancancode).
|
186
187
|
|
187
188
|
## License
|
188
189
|
|
@@ -12,6 +12,11 @@ module Mongoid
|
|
12
12
|
self
|
13
13
|
end
|
14
14
|
|
15
|
+
def on(*contexts)
|
16
|
+
@expected_on = clean_contexts(contexts)
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
15
20
|
def matches?(subject)
|
16
21
|
@klass = class_of(subject)
|
17
22
|
@validator = detect_validator
|
@@ -19,6 +24,7 @@ module Mongoid
|
|
19
24
|
|
20
25
|
check_validator
|
21
26
|
check_message if @expected_message
|
27
|
+
check_on if @expected_on
|
22
28
|
|
23
29
|
@result
|
24
30
|
end
|
@@ -34,18 +40,24 @@ module Mongoid
|
|
34
40
|
def description
|
35
41
|
desc = "validate #{@type.inspect} of #{@field.inspect}"
|
36
42
|
desc << " with message: #{@expected_message.inspect}" if @expected_message
|
43
|
+
desc << " on #{@expected_on.empty? ? 'all actions' : to_sentence(@expected_on)}" if @expected_on
|
37
44
|
|
38
45
|
desc
|
39
46
|
end
|
40
47
|
|
41
48
|
private
|
42
49
|
|
50
|
+
# Make sure contexts is always an array + normalize AR 2.x and AR 3.x differences
|
51
|
+
def clean_contexts(contexts)
|
52
|
+
[contexts].flatten.reject{|ctx| ctx == :save}.compact
|
53
|
+
end
|
54
|
+
|
43
55
|
def check_validator
|
44
56
|
if @validator
|
45
|
-
@negative_message = "#{@type.inspect} validator
|
46
|
-
@positive_message = "#{@type.inspect} validator
|
57
|
+
@negative_message = "#{@type.inspect} validator for #{@field.inspect}"
|
58
|
+
@positive_message = "#{@type.inspect} validator for #{@field.inspect}"
|
47
59
|
else
|
48
|
-
@negative_message = "no #{@type.inspect} validator
|
60
|
+
@negative_message = "no #{@type.inspect} validator for #{@field.inspect}"
|
49
61
|
@result = false
|
50
62
|
end
|
51
63
|
end
|
@@ -60,6 +72,16 @@ module Mongoid
|
|
60
72
|
end
|
61
73
|
end
|
62
74
|
|
75
|
+
def check_on
|
76
|
+
on = clean_contexts(@validator.options[:on])
|
77
|
+
if on.sort == @expected_on.sort
|
78
|
+
@positive_message << " on #{on.empty? ? 'all actions' : to_sentence(on)}"
|
79
|
+
else
|
80
|
+
@negative_message << " on #{on.empty? ? 'all actions' : to_sentence(on)}"
|
81
|
+
@result = false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
63
85
|
def detect_validator
|
64
86
|
@klass.validators_on(@field).detect { |v| v.kind.to_s == @type }
|
65
87
|
end
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-minitest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Francesco Rodriguez
|
9
9
|
- Sascha Wessel
|
10
|
+
- Godfrey Chan
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2012-08
|
14
|
+
date: 2012-09-08 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: minitest
|
@@ -19,7 +20,7 @@ dependencies:
|
|
19
20
|
requirements:
|
20
21
|
- - ~>
|
21
22
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.
|
23
|
+
version: 3.4.0
|
23
24
|
type: :runtime
|
24
25
|
prerelease: false
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +28,7 @@ dependencies:
|
|
27
28
|
requirements:
|
28
29
|
- - ~>
|
29
30
|
- !ruby/object:Gem::Version
|
30
|
-
version: 3.
|
31
|
+
version: 3.4.0
|
31
32
|
- !ruby/object:Gem::Dependency
|
32
33
|
name: minitest-matchers
|
33
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,7 +52,7 @@ dependencies:
|
|
51
52
|
requirements:
|
52
53
|
- - ~>
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.0.
|
55
|
+
version: 3.0.5
|
55
56
|
type: :runtime
|
56
57
|
prerelease: false
|
57
58
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,7 +60,7 @@ dependencies:
|
|
59
60
|
requirements:
|
60
61
|
- - ~>
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3.0.
|
63
|
+
version: 3.0.5
|
63
64
|
- !ruby/object:Gem::Dependency
|
64
65
|
name: rake
|
65
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,9 +121,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
122
|
none: false
|
122
123
|
requirements:
|
123
|
-
- - ! '
|
124
|
+
- - ! '>'
|
124
125
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
126
|
+
version: 1.3.1
|
126
127
|
requirements: []
|
127
128
|
rubyforge_project:
|
128
129
|
rubygems_version: 1.8.23
|