mutations 0.9.0 → 0.9.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/.github/workflows/ci.yml +35 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +0 -6
- data/README.md +1 -1
- data/Rakefile +0 -1
- data/lib/mutations/array_filter.rb +1 -2
- data/lib/mutations/command.rb +1 -1
- data/lib/mutations/date_filter.rb +7 -5
- data/lib/mutations/hash_filter.rb +1 -4
- data/lib/mutations/integer_filter.rb +7 -6
- data/lib/mutations/string_filter.rb +9 -8
- data/lib/mutations/version.rb +1 -1
- data/mutations.gemspec +1 -1
- data/spec/additional_filter_spec.rb +3 -3
- data/spec/array_filter_spec.rb +19 -19
- data/spec/boolean_filter_spec.rb +6 -6
- data/spec/command_spec.rb +17 -16
- data/spec/date_filter_spec.rb +19 -23
- data/spec/default_spec.rb +2 -2
- data/spec/duck_filter_spec.rb +6 -6
- data/spec/errors_spec.rb +14 -14
- data/spec/file_filter_spec.rb +14 -18
- data/spec/float_filter_spec.rb +11 -11
- data/spec/hash_filter_spec.rb +36 -36
- data/spec/integer_filter_spec.rb +10 -10
- data/spec/model_filter_spec.rb +7 -7
- data/spec/mutations_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/string_filter_spec.rb +52 -29
- data/spec/symbol_filter_spec.rb +6 -6
- data/spec/time_filter_spec.rb +16 -16
- metadata +11 -11
- data/.travis.yml +0 -15
data/spec/integer_filter_spec.rb
CHANGED
|
@@ -6,21 +6,21 @@ describe "Mutations::IntegerFilter" do
|
|
|
6
6
|
f = Mutations::IntegerFilter.new
|
|
7
7
|
filtered, errors = f.filter(3)
|
|
8
8
|
assert_equal 3, filtered
|
|
9
|
-
|
|
9
|
+
assert_nil errors
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "allows strings that start with a digit" do
|
|
13
13
|
f = Mutations::IntegerFilter.new
|
|
14
14
|
filtered, errors = f.filter("3")
|
|
15
15
|
assert_equal 3, filtered
|
|
16
|
-
|
|
16
|
+
assert_nil errors
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "allows negative strings" do
|
|
20
20
|
f = Mutations::IntegerFilter.new
|
|
21
21
|
filtered, errors = f.filter("-3")
|
|
22
22
|
assert_equal(-3, filtered)
|
|
23
|
-
|
|
23
|
+
assert_nil errors
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "doesnt't allow other strings, nor does it allow random objects or symbols" do
|
|
@@ -34,15 +34,15 @@ describe "Mutations::IntegerFilter" do
|
|
|
34
34
|
it "considers nil to be invalid" do
|
|
35
35
|
f = Mutations::IntegerFilter.new(:nils => false)
|
|
36
36
|
filtered, errors = f.filter(nil)
|
|
37
|
-
|
|
37
|
+
assert_nil filtered
|
|
38
38
|
assert_equal :nils, errors
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "considers nil to be valid" do
|
|
42
42
|
f = Mutations::IntegerFilter.new(:nils => true)
|
|
43
43
|
filtered, errors = f.filter(nil)
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
assert_nil filtered
|
|
45
|
+
assert_nil errors
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "considers empty strings to be empty" do
|
|
@@ -60,8 +60,8 @@ describe "Mutations::IntegerFilter" do
|
|
|
60
60
|
it "returns empty strings as nil if empty_is_nil option is used" do
|
|
61
61
|
f = Mutations::IntegerFilter.new(:empty_is_nil => true, :nils => true)
|
|
62
62
|
filtered, errors = f.filter("")
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
assert_nil filtered
|
|
64
|
+
assert_nil errors
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "considers low numbers invalid" do
|
|
@@ -75,7 +75,7 @@ describe "Mutations::IntegerFilter" do
|
|
|
75
75
|
f = Mutations::IntegerFilter.new(:min => 10)
|
|
76
76
|
filtered, errors = f.filter(31)
|
|
77
77
|
assert_equal 31, filtered
|
|
78
|
-
|
|
78
|
+
assert_nil errors
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "considers high numbers invalid" do
|
|
@@ -89,7 +89,7 @@ describe "Mutations::IntegerFilter" do
|
|
|
89
89
|
f = Mutations::IntegerFilter.new(:max => 10)
|
|
90
90
|
filtered, errors = f.filter(3)
|
|
91
91
|
assert_equal 3, filtered
|
|
92
|
-
|
|
92
|
+
assert_nil errors
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "considers not matching numbers to be invalid" do
|
data/spec/model_filter_spec.rb
CHANGED
|
@@ -20,7 +20,7 @@ describe "Mutations::ModelFilter" do
|
|
|
20
20
|
m = SimpleModel.new
|
|
21
21
|
filtered, errors = f.filter(m)
|
|
22
22
|
assert_equal m, filtered
|
|
23
|
-
|
|
23
|
+
assert_nil errors
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# it "disallows different types of models" do
|
|
@@ -50,15 +50,15 @@ describe "Mutations::ModelFilter" do
|
|
|
50
50
|
it "considers nil to be invalid" do
|
|
51
51
|
f = Mutations::ModelFilter.new(:simple_model, :nils => false)
|
|
52
52
|
filtered, errors = f.filter(nil)
|
|
53
|
-
|
|
53
|
+
assert_nil filtered
|
|
54
54
|
assert_equal :nils, errors
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "considers nil to be valid" do
|
|
58
58
|
f = Mutations::ModelFilter.new(:simple_model, :nils => true)
|
|
59
59
|
filtered, errors = f.filter(nil)
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
assert_nil filtered
|
|
61
|
+
assert_nil errors
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "will not re-constantize if cache_constants is true" do
|
|
@@ -68,7 +68,7 @@ describe "Mutations::ModelFilter" do
|
|
|
68
68
|
m = SimpleModel.new
|
|
69
69
|
filtered, errors = f.filter(m)
|
|
70
70
|
assert_equal m, filtered
|
|
71
|
-
|
|
71
|
+
assert_nil errors
|
|
72
72
|
|
|
73
73
|
Object.send(:remove_const, 'SimpleModel')
|
|
74
74
|
|
|
@@ -89,7 +89,7 @@ describe "Mutations::ModelFilter" do
|
|
|
89
89
|
m = SimpleModel.new
|
|
90
90
|
filtered, errors = f.filter(m)
|
|
91
91
|
assert_equal m, filtered
|
|
92
|
-
|
|
92
|
+
assert_nil errors
|
|
93
93
|
|
|
94
94
|
Object.send(:remove_const, 'SimpleModel')
|
|
95
95
|
|
|
@@ -98,7 +98,7 @@ describe "Mutations::ModelFilter" do
|
|
|
98
98
|
m = SimpleModel.new
|
|
99
99
|
filtered, errors = f.filter(m)
|
|
100
100
|
assert_equal m, filtered
|
|
101
|
-
|
|
101
|
+
assert_nil errors
|
|
102
102
|
|
|
103
103
|
Mutations.cache_constants = was
|
|
104
104
|
end
|
data/spec/mutations_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/string_filter_spec.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe "Mutations::StringFilter" do
|
|
@@ -6,21 +8,21 @@ describe "Mutations::StringFilter" do
|
|
|
6
8
|
sf = Mutations::StringFilter.new
|
|
7
9
|
filtered, errors = sf.filter("hello")
|
|
8
10
|
assert_equal "hello", filtered
|
|
9
|
-
|
|
11
|
+
assert_nil errors
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it "allows symbols" do
|
|
13
15
|
sf = Mutations::StringFilter.new
|
|
14
16
|
filtered, errors = sf.filter(:hello)
|
|
15
17
|
assert_equal "hello", filtered
|
|
16
|
-
|
|
18
|
+
assert_nil errors
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
it "allows
|
|
21
|
+
it "allows numbers" do
|
|
20
22
|
sf = Mutations::StringFilter.new
|
|
21
23
|
filtered, errors = sf.filter(1)
|
|
22
24
|
assert_equal "1", filtered
|
|
23
|
-
|
|
25
|
+
assert_nil errors
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
it "disallows non-string" do
|
|
@@ -35,28 +37,28 @@ describe "Mutations::StringFilter" do
|
|
|
35
37
|
sf = Mutations::StringFilter.new(:strip => true)
|
|
36
38
|
filtered, errors = sf.filter(" hello ")
|
|
37
39
|
assert_equal "hello", filtered
|
|
38
|
-
|
|
40
|
+
assert_nil errors
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
it "doesn't strip" do
|
|
42
44
|
sf = Mutations::StringFilter.new(:strip => false)
|
|
43
45
|
filtered, errors = sf.filter(" hello ")
|
|
44
46
|
assert_equal " hello ", filtered
|
|
45
|
-
|
|
47
|
+
assert_nil errors
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
it "considers nil to be invalid" do
|
|
49
51
|
sf = Mutations::StringFilter.new(:nils => false)
|
|
50
52
|
filtered, errors = sf.filter(nil)
|
|
51
|
-
|
|
53
|
+
assert_nil filtered
|
|
52
54
|
assert_equal :nils, errors
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
it "considers nil to be valid" do
|
|
56
58
|
sf = Mutations::StringFilter.new(:nils => true)
|
|
57
59
|
filtered, errors = sf.filter(nil)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
assert_nil filtered
|
|
61
|
+
assert_nil errors
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
it "considers empty strings to be nil if empty_is_nil option is used" do
|
|
@@ -68,8 +70,8 @@ describe "Mutations::StringFilter" do
|
|
|
68
70
|
it "returns empty strings as nil if empty_is_nil option is used" do
|
|
69
71
|
f = Mutations::StringFilter.new(:empty_is_nil => true, :nils => true)
|
|
70
72
|
filtered, errors = f.filter("")
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
assert_nil filtered
|
|
74
|
+
assert_nil errors
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
it "considers empty strings to be invalid" do
|
|
@@ -83,7 +85,7 @@ describe "Mutations::StringFilter" do
|
|
|
83
85
|
sf = Mutations::StringFilter.new(:empty => true)
|
|
84
86
|
filtered, errors = sf.filter("")
|
|
85
87
|
assert_equal "", filtered
|
|
86
|
-
|
|
88
|
+
assert_nil errors
|
|
87
89
|
end
|
|
88
90
|
|
|
89
91
|
it "considers stripped strings that are empty to be invalid" do
|
|
@@ -93,7 +95,21 @@ describe "Mutations::StringFilter" do
|
|
|
93
95
|
assert_equal :empty, errors
|
|
94
96
|
end
|
|
95
97
|
|
|
96
|
-
it "considers strings that
|
|
98
|
+
it "considers stripped strings that are blank to be nil if empty_is_nil option is used" do
|
|
99
|
+
sf = Mutations::StringFilter.new(:strip => true, :empty_is_nil => true, :nils => true)
|
|
100
|
+
filtered, errors = sf.filter(" ")
|
|
101
|
+
assert_nil filtered
|
|
102
|
+
assert_nil errors
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it "considers stripped strings that are blank to be invalid if empty_is_nil option is used" do
|
|
106
|
+
sf = Mutations::StringFilter.new(:strip => true, :empty_is_nil => true)
|
|
107
|
+
filtered, errors = sf.filter(" ")
|
|
108
|
+
assert_nil filtered
|
|
109
|
+
assert_equal :nils, errors
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "considers strings that contain only control characters to be invalid" do
|
|
97
113
|
sf = Mutations::StringFilter.new(:empty => false)
|
|
98
114
|
filtered, errors = sf.filter("\u0000\u0000")
|
|
99
115
|
assert_equal "", filtered
|
|
@@ -111,7 +127,7 @@ describe "Mutations::StringFilter" do
|
|
|
111
127
|
sf = Mutations::StringFilter.new(:max_length => 5)
|
|
112
128
|
filtered, errors = sf.filter("12345")
|
|
113
129
|
assert_equal "12345", filtered
|
|
114
|
-
|
|
130
|
+
assert_nil errors
|
|
115
131
|
end
|
|
116
132
|
|
|
117
133
|
it "considers short strings to be invalid" do
|
|
@@ -125,7 +141,7 @@ describe "Mutations::StringFilter" do
|
|
|
125
141
|
sf = Mutations::StringFilter.new(:min_length => 5)
|
|
126
142
|
filtered, errors = sf.filter("12345")
|
|
127
143
|
assert_equal "12345", filtered
|
|
128
|
-
|
|
144
|
+
assert_nil errors
|
|
129
145
|
end
|
|
130
146
|
|
|
131
147
|
it "considers bad matches to be invalid" do
|
|
@@ -139,7 +155,7 @@ describe "Mutations::StringFilter" do
|
|
|
139
155
|
sf = Mutations::StringFilter.new(:matches => /aaa/)
|
|
140
156
|
filtered, errors = sf.filter("baaab")
|
|
141
157
|
assert_equal "baaab", filtered
|
|
142
|
-
|
|
158
|
+
assert_nil errors
|
|
143
159
|
end
|
|
144
160
|
|
|
145
161
|
it "considers non-inclusion to be invalid" do
|
|
@@ -153,42 +169,42 @@ describe "Mutations::StringFilter" do
|
|
|
153
169
|
sf = Mutations::StringFilter.new(:in => %w(red blue green))
|
|
154
170
|
filtered, errors = sf.filter("red")
|
|
155
171
|
assert_equal "red", filtered
|
|
156
|
-
|
|
172
|
+
assert_nil errors
|
|
157
173
|
end
|
|
158
174
|
|
|
159
175
|
it "converts symbols to strings" do
|
|
160
176
|
sf = Mutations::StringFilter.new(:strict => false)
|
|
161
177
|
filtered, errors = sf.filter(:my_sym)
|
|
162
178
|
assert_equal "my_sym", filtered
|
|
163
|
-
|
|
179
|
+
assert_nil errors
|
|
164
180
|
end
|
|
165
181
|
|
|
166
182
|
it "converts integers to strings" do
|
|
167
183
|
sf = Mutations::StringFilter.new(:strict => false)
|
|
168
184
|
filtered, errors = sf.filter(1)
|
|
169
185
|
assert_equal "1", filtered
|
|
170
|
-
|
|
186
|
+
assert_nil errors
|
|
171
187
|
end
|
|
172
188
|
|
|
173
189
|
it "converts bigdecimals to strings" do
|
|
174
190
|
sf = Mutations::StringFilter.new(:strict => false)
|
|
175
|
-
filtered, errors = sf.filter(BigDecimal
|
|
191
|
+
filtered, errors = sf.filter(BigDecimal("0.0001"))
|
|
176
192
|
assert_equal("0.1E-3", filtered.upcase)
|
|
177
|
-
|
|
193
|
+
assert_nil errors
|
|
178
194
|
end
|
|
179
195
|
|
|
180
196
|
it "converts floats to strings" do
|
|
181
197
|
sf = Mutations::StringFilter.new(:strict => false)
|
|
182
198
|
filtered, errors = sf.filter(0.0001)
|
|
183
199
|
assert_equal "0.0001", filtered
|
|
184
|
-
|
|
200
|
+
assert_nil errors
|
|
185
201
|
end
|
|
186
202
|
|
|
187
203
|
it "converts booleans to strings" do
|
|
188
204
|
sf = Mutations::StringFilter.new(:strict => false)
|
|
189
205
|
filtered, errors = sf.filter(true)
|
|
190
206
|
assert_equal "true", filtered
|
|
191
|
-
|
|
207
|
+
assert_nil errors
|
|
192
208
|
end
|
|
193
209
|
|
|
194
210
|
it "disallows symbols" do
|
|
@@ -207,7 +223,7 @@ describe "Mutations::StringFilter" do
|
|
|
207
223
|
|
|
208
224
|
it "disallows bigdecimals" do
|
|
209
225
|
sf = Mutations::StringFilter.new(:strict => true)
|
|
210
|
-
big_decimal = BigDecimal
|
|
226
|
+
big_decimal = BigDecimal("0.0001")
|
|
211
227
|
filtered, errors = sf.filter(big_decimal)
|
|
212
228
|
assert_equal big_decimal, filtered
|
|
213
229
|
assert_equal :string, errors
|
|
@@ -227,25 +243,32 @@ describe "Mutations::StringFilter" do
|
|
|
227
243
|
assert_equal :string, errors
|
|
228
244
|
end
|
|
229
245
|
|
|
230
|
-
it "removes
|
|
246
|
+
it "removes control characters" do
|
|
231
247
|
sf = Mutations::StringFilter.new(:allow_control_characters => false)
|
|
232
248
|
filtered, errors = sf.filter("Hello\u0000\u0000World!")
|
|
233
249
|
assert_equal "Hello World!", filtered
|
|
234
|
-
|
|
250
|
+
assert_nil errors
|
|
235
251
|
end
|
|
236
252
|
|
|
237
|
-
it "doesn't remove
|
|
253
|
+
it "doesn't remove control characters" do
|
|
238
254
|
sf = Mutations::StringFilter.new(:allow_control_characters => true)
|
|
239
255
|
filtered, errors = sf.filter("Hello\u0000\u0000World!")
|
|
240
256
|
assert_equal "Hello\u0000\u0000World!", filtered
|
|
241
|
-
|
|
257
|
+
assert_nil errors
|
|
242
258
|
end
|
|
243
259
|
|
|
244
260
|
it "doesn't remove tabs, spaces and line breaks" do
|
|
245
261
|
sf = Mutations::StringFilter.new(:allow_control_characters => false)
|
|
246
262
|
filtered, errors = sf.filter("Hello,\tWorld !\r\nNew Line")
|
|
247
263
|
assert_equal "Hello,\tWorld !\r\nNew Line", filtered
|
|
248
|
-
|
|
264
|
+
assert_nil errors
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "doesn't remove emoji" do
|
|
268
|
+
sf = Mutations::StringFilter.new(:allow_control_characters => false)
|
|
269
|
+
filtered, errors = sf.filter("😂🙂🙃🤣🤩🥰🥱")
|
|
270
|
+
assert_equal "😂🙂🙃🤣🤩🥰🥱", filtered
|
|
271
|
+
assert_nil errors
|
|
249
272
|
end
|
|
250
273
|
|
|
251
274
|
end
|
data/spec/symbol_filter_spec.rb
CHANGED
|
@@ -6,14 +6,14 @@ describe "Mutations::SymbolFilter" do
|
|
|
6
6
|
sf = Mutations::SymbolFilter.new
|
|
7
7
|
filtered, errors = sf.filter("hello")
|
|
8
8
|
assert_equal :hello, filtered
|
|
9
|
-
|
|
9
|
+
assert_nil errors
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "allows symbols" do
|
|
13
13
|
sf = Mutations::SymbolFilter.new
|
|
14
14
|
filtered, errors = sf.filter(:hello)
|
|
15
15
|
assert_equal :hello, filtered
|
|
16
|
-
|
|
16
|
+
assert_nil errors
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "doesn't allow non-symbols" do
|
|
@@ -27,15 +27,15 @@ describe "Mutations::SymbolFilter" do
|
|
|
27
27
|
it "considers nil to be invalid" do
|
|
28
28
|
sf = Mutations::SymbolFilter.new(:nils => false)
|
|
29
29
|
filtered, errors = sf.filter(nil)
|
|
30
|
-
|
|
30
|
+
assert_nil filtered
|
|
31
31
|
assert_equal :nils, errors
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "considers nil to be valid" do
|
|
35
35
|
sf = Mutations::SymbolFilter.new(:nils => true)
|
|
36
36
|
filtered, errors = sf.filter(nil)
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
assert_nil filtered
|
|
38
|
+
assert_nil errors
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "considers non-inclusion to be invalid" do
|
|
@@ -49,7 +49,7 @@ describe "Mutations::SymbolFilter" do
|
|
|
49
49
|
sf = Mutations::SymbolFilter.new(:in => [:red, :blue, :green])
|
|
50
50
|
filtered, errors = sf.filter(:red)
|
|
51
51
|
assert_equal :red, filtered
|
|
52
|
-
|
|
52
|
+
assert_nil errors
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
end
|
data/spec/time_filter_spec.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe "Mutations::TimeFilter" do
|
|
|
7
7
|
f = Mutations::TimeFilter.new
|
|
8
8
|
filtered, errors = f.filter(time)
|
|
9
9
|
assert_equal time, filtered
|
|
10
|
-
|
|
10
|
+
assert_nil errors
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "takes a Date object and converts it to a time" do
|
|
@@ -15,7 +15,7 @@ describe "Mutations::TimeFilter" do
|
|
|
15
15
|
f = Mutations::TimeFilter.new
|
|
16
16
|
filtered, errors = f.filter(date)
|
|
17
17
|
assert_equal date.to_time, filtered
|
|
18
|
-
|
|
18
|
+
assert_nil errors
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "takes a DateTime object and converts it to a time" do
|
|
@@ -23,7 +23,7 @@ describe "Mutations::TimeFilter" do
|
|
|
23
23
|
f = Mutations::TimeFilter.new
|
|
24
24
|
filtered, errors = f.filter(date)
|
|
25
25
|
assert_equal date.to_time, filtered
|
|
26
|
-
|
|
26
|
+
assert_nil errors
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "checks if the given time is after a certain time" do
|
|
@@ -31,14 +31,14 @@ describe "Mutations::TimeFilter" do
|
|
|
31
31
|
f = Mutations::TimeFilter.new(:after => time - 1)
|
|
32
32
|
filtered, errors = f.filter(time)
|
|
33
33
|
assert_equal time, filtered
|
|
34
|
-
|
|
34
|
+
assert_nil errors
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
it "gives errors when the given time is before the after time" do
|
|
38
38
|
time = Time.now
|
|
39
39
|
f = Mutations::TimeFilter.new(:after => time + 1)
|
|
40
40
|
filtered, errors = f.filter(time)
|
|
41
|
-
|
|
41
|
+
assert_nil filtered
|
|
42
42
|
assert_equal :after, errors
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -47,14 +47,14 @@ describe "Mutations::TimeFilter" do
|
|
|
47
47
|
f = Mutations::TimeFilter.new(:before => time + 1)
|
|
48
48
|
filtered, errors = f.filter(time)
|
|
49
49
|
assert_equal time, filtered
|
|
50
|
-
|
|
50
|
+
assert_nil errors
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "gives errors when the given time is after the before time" do
|
|
54
54
|
time = Time.now
|
|
55
55
|
f = Mutations::TimeFilter.new(:before => time - 1)
|
|
56
56
|
filtered, errors = f.filter(time)
|
|
57
|
-
|
|
57
|
+
assert_nil filtered
|
|
58
58
|
assert_equal :before, errors
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -63,7 +63,7 @@ describe "Mutations::TimeFilter" do
|
|
|
63
63
|
f = Mutations::TimeFilter.new(:after => time - 1, :before => time + 1)
|
|
64
64
|
filtered, errors = f.filter(time)
|
|
65
65
|
assert_equal time, filtered
|
|
66
|
-
|
|
66
|
+
assert_nil errors
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "should be able to parse a D-M-Y string to a time" do
|
|
@@ -72,7 +72,7 @@ describe "Mutations::TimeFilter" do
|
|
|
72
72
|
f = Mutations::TimeFilter.new
|
|
73
73
|
filtered, errors = f.filter(date_string)
|
|
74
74
|
assert_equal date.to_time, filtered
|
|
75
|
-
|
|
75
|
+
assert_nil errors
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
it "should be able to parse a Y-M-D string to a time" do
|
|
@@ -81,7 +81,7 @@ describe "Mutations::TimeFilter" do
|
|
|
81
81
|
f = Mutations::TimeFilter.new
|
|
82
82
|
filtered, errors = f.filter(date_string)
|
|
83
83
|
assert_equal date.to_time, filtered
|
|
84
|
-
|
|
84
|
+
assert_nil errors
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
it "should be able to handle time formatting" do
|
|
@@ -90,27 +90,27 @@ describe "Mutations::TimeFilter" do
|
|
|
90
90
|
f = Mutations::TimeFilter.new(:format => '%Y-%m-%d %H:%M:%S')
|
|
91
91
|
filtered, errors = f.filter(time_string)
|
|
92
92
|
assert_equal time, filtered
|
|
93
|
-
|
|
93
|
+
assert_nil errors
|
|
94
94
|
|
|
95
95
|
time_string = "1, 2, 2000, 121314"
|
|
96
96
|
f = Mutations::TimeFilter.new(:format => '%m, %d, %Y, %H%M%S')
|
|
97
97
|
filtered, errors = f.filter(time_string)
|
|
98
98
|
assert_equal time, filtered
|
|
99
|
-
|
|
99
|
+
assert_nil errors
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
it "considers nil to be invalid" do
|
|
103
103
|
f = Mutations::TimeFilter.new
|
|
104
104
|
filtered, errors = f.filter(nil)
|
|
105
|
-
|
|
105
|
+
assert_nil filtered
|
|
106
106
|
assert_equal :nils, errors
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
it "allows the use of nil when specified" do
|
|
110
110
|
f = Mutations::TimeFilter.new(:nils => true)
|
|
111
111
|
filtered, errors = f.filter(nil)
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
assert_nil filtered
|
|
113
|
+
assert_nil errors
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
it "considers empty strings to be empty" do
|
|
@@ -124,7 +124,7 @@ describe "Mutations::TimeFilter" do
|
|
|
124
124
|
invalid_time_string = "1, 20, 2013 25:13"
|
|
125
125
|
f = Mutations::TimeFilter.new
|
|
126
126
|
filtered, errors = f.filter(invalid_time_string)
|
|
127
|
-
|
|
127
|
+
assert_nil filtered
|
|
128
128
|
assert_equal :time, errors
|
|
129
129
|
end
|
|
130
130
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mutations
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Novak
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -28,16 +28,16 @@ dependencies:
|
|
|
28
28
|
name: minitest
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,8 +59,8 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- ".github/workflows/ci.yml"
|
|
62
63
|
- ".gitignore"
|
|
63
|
-
- ".travis.yml"
|
|
64
64
|
- CHANGELOG.md
|
|
65
65
|
- Gemfile
|
|
66
66
|
- MIT-LICENSE
|
|
@@ -112,7 +112,7 @@ homepage: http://github.com/cypriss/mutations
|
|
|
112
112
|
licenses:
|
|
113
113
|
- MIT
|
|
114
114
|
metadata: {}
|
|
115
|
-
post_install_message:
|
|
115
|
+
post_install_message:
|
|
116
116
|
rdoc_options: []
|
|
117
117
|
require_paths:
|
|
118
118
|
- lib
|
|
@@ -127,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
127
|
- !ruby/object:Gem::Version
|
|
128
128
|
version: '0'
|
|
129
129
|
requirements: []
|
|
130
|
-
rubygems_version: 3.
|
|
131
|
-
signing_key:
|
|
130
|
+
rubygems_version: 3.4.10
|
|
131
|
+
signing_key:
|
|
132
132
|
specification_version: 4
|
|
133
133
|
summary: Compose your business logic into commands that sanitize and validate input.
|
|
134
134
|
test_files: []
|
data/.travis.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
dist: trusty
|
|
3
|
-
sudo: required
|
|
4
|
-
before_install:
|
|
5
|
-
- gem install bundler # the default bundler version on travis is very old and causes 1.9.3 build issues
|
|
6
|
-
rvm:
|
|
7
|
-
- 1.9.3
|
|
8
|
-
- jruby-1.7.26
|
|
9
|
-
- 2.0.0
|
|
10
|
-
- 2.1.10
|
|
11
|
-
- 2.2.6
|
|
12
|
-
- 2.3.3
|
|
13
|
-
- 2.4.0
|
|
14
|
-
- jruby-9.1.7.0
|
|
15
|
-
- rbx-3
|