Method: CodeDrivenDevelopment::Rule::Set#test_for
- Defined in:
- lib/code_driven_development/rule/set.rb
#test_for(code, test_context) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/code_driven_development/rule/set.rb', line 9 def test_for(code, test_context) capable_rules = rules.map do |klass| klass.new(code, self, test_context) end.select(&:capable?) case capable_rules.count when 0 default_rule.new(code, self, test_context).test when 1 capable_rules.first.test else raise "Multiple rules matched #{code.inspect}:\n\t" + capable_rules.map(&:class).map(&:to_s).join("\n\t") end end |