array_logic 0.0.3 → 0.0.4

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.
@@ -37,11 +37,11 @@ module ArrayLogic
37
37
  end
38
38
 
39
39
  def combinations_that_match
40
- combinations_of_identifiers_in_rule.delete_if{|ids| ! match_ids(ids)}
40
+ combinations_of_identifiers_in_rule.delete_if{|ids| ! match_ids(ids)} if rule and !rule.empty?
41
41
  end
42
42
 
43
43
  def combinations_that_do_not_match
44
- combinations_of_identifiers_in_rule.delete_if{|ids| match_ids(ids)}
44
+ combinations_of_identifiers_in_rule.delete_if{|ids| match_ids(ids)} if rule and !rule.empty?
45
45
  end
46
46
 
47
47
  private
@@ -1,3 +1,3 @@
1
1
  module ArrayLogic
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -234,6 +234,13 @@ module ArrayLogic
234
234
  assert_equal([[1,2]], @rule.combinations_that_match)
235
235
  end
236
236
 
237
+ def test_combinations_that_match_without_rule
238
+ @rule.rule = nil
239
+ assert_nil(@rule.combinations_that_match, "combinations_that_match should return nil if there is no rule")
240
+ @rule.rule = ""
241
+ assert_nil(@rule.combinations_that_match, "combinations_that_match should return nil if the rule is blank")
242
+ end
243
+
237
244
  def test_combinations_that_do_not_match
238
245
  @rule.rule = 't1 or t2'
239
246
  assert_equal([], @rule.combinations_that_do_not_match)
@@ -241,5 +248,17 @@ module ArrayLogic
241
248
  assert_equal([[1],[2]], @rule.combinations_that_do_not_match)
242
249
  end
243
250
 
251
+ def test_combinations_that_do_not_match_without_rule
252
+ @rule.rule = nil
253
+ assert_nil(@rule.combinations_that_do_not_match, "combinations_that_do_not_match should return nil if there is no rule")
254
+ @rule.rule = ""
255
+ assert_nil(@rule.combinations_that_do_not_match, "combinations_that_do_not_match should return nil if the rule is blank")
256
+ end
257
+
258
+ def test_combinations_that_do_not_match_when_none_returned
259
+ @rule.rule = 't1'
260
+ assert_equal([], @rule.combinations_that_do_not_match)
261
+ end
262
+
244
263
  end
245
264
  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.3
4
+ version: 0.0.4
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-27 00:00:00.000000000 Z
12
+ date: 2012-11-28 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.