array_logic 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/array_logic/rule.rb +1 -1
- data/lib/array_logic/version.rb +1 -1
- data/test/array_logic/rule_test.rb +11 -1
- metadata +2 -2
data/lib/array_logic/rule.rb
CHANGED
data/lib/array_logic/version.rb
CHANGED
@@ -227,6 +227,11 @@ module ArrayLogic
|
|
227
227
|
assert_equal([1, 2, 3, 4], @rule.object_ids_used)
|
228
228
|
end
|
229
229
|
|
230
|
+
def test_object_ids_user_does_not_return_duplicates
|
231
|
+
@rule.rule = 't1 and t2 and (2 in t1 t2)'
|
232
|
+
assert_equal([1, 2], @rule.object_ids_used)
|
233
|
+
end
|
234
|
+
|
230
235
|
def test_combinations_that_match
|
231
236
|
@rule.rule = 't1 or t2'
|
232
237
|
assert_equal([[1], [2], [1,2]], @rule.combinations_that_match)
|
@@ -241,6 +246,11 @@ module ArrayLogic
|
|
241
246
|
assert_nil(@rule.combinations_that_match, "combinations_that_match should return nil if the rule is blank")
|
242
247
|
end
|
243
248
|
|
249
|
+
def test_combinations_that_match_with_duplicate_ids
|
250
|
+
@rule.rule = 't1 and t2 and (2 in t1 t2)'
|
251
|
+
assert_equal(1, @rule.combinations_that_match.length, "should not identify combinations for both occurancies of each id")
|
252
|
+
end
|
253
|
+
|
244
254
|
def test_combinations_that_do_not_match
|
245
255
|
@rule.rule = 't1 or t2'
|
246
256
|
assert_equal([], @rule.combinations_that_do_not_match)
|
@@ -259,6 +269,6 @@ module ArrayLogic
|
|
259
269
|
@rule.rule = 't1'
|
260
270
|
assert_equal([], @rule.combinations_that_do_not_match)
|
261
271
|
end
|
262
|
-
|
272
|
+
|
263
273
|
end
|
264
274
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: array_logic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allow a user to define a set of rules, and then test to see if an array
|
15
15
|
of object match those rules.
|