spec/rbrules_spec.rb in rbrules-0.1.0 vs spec/rbrules_spec.rb in rbrules-0.1.1

- old
+ new

@@ -10,10 +10,14 @@ rules.rule(:hello) { |param| param =~ /hello/ } rules.rule(:world) { |param| param =~ /world/ } end end + def test_number_of_rules + assert_equal 2, rb_rules.rules.size + end + def test_any? assert rb_rules.any?('hello') assert rb_rules.any?('world') end @@ -30,19 +34,29 @@ def test_none? assert rb_rules.none?('none') refute rb_rules.none?('hello') end + def test_sum + + rb_rule_extra = RbRules.new do |rules| + rules.rule(:extra) { true } + end + + combined_rules = rb_rules + rb_rule_extra + + assert_equal 3, combined_rules.rules.size + assert rb_rule_extra.rules.all? { |r| combined_rules.rules.include?(r) } + end + end class TestSingleton < TestRbRules - def setup - rb_rules.rule(:hello) { |param| param =~ /hello/ } - rb_rules.rule ->(param) { param =~ /world/ } - end + RbRules[:test].rule(:hello) { |param| param =~ /hello/ } + RbRules[:test].rule ->(param) { param =~ /world/ } - def rb_rules - RbRules[:test] + def setup + @rb_rules = RbRules[:test] end end