lib/atp/processors/pre_cleaner.rb in atp-0.8.0 vs lib/atp/processors/pre_cleaner.rb in atp-1.0.0

- old
+ new

@@ -1,10 +1,10 @@ module ATP module Processors # Modifies the AST by performing some basic clean up, mainly to sanitize - # user input. For example it will ensure that all IDs are symbols, and that - # all names are lower-cased strings. + # user input. For example it will ensure that all IDs and references are underscored + # and lower cased. class PreCleaner < Processor def initialize @group_ids = [] end @@ -13,16 +13,21 @@ id = node.to_a[0] node.updated(nil, [clean(id)]) end # Make all ID references use the lower case symbols - def on_test_executed(node) - children = node.children.dup - children[0] = clean(children[0]) - node.updated(nil, process_all(children)) + def on_if_failed(node) + id, *children = *node + node.updated(nil, [clean(id)] + process_all(children)) end - alias_method :on_test_result, :on_test_executed + alias_method :on_if_passed, :on_if_failed + alias_method :on_if_any_failed, :on_if_failed + alias_method :on_if_all_failed, :on_if_failed + alias_method :on_if_any_passed, :on_if_failed + alias_method :on_if_all_passed, :on_if_failed + alias_method :on_if_ran, :on_if_failed + alias_method :on_unless_ran, :on_if_failed def on_group(node) if id = node.children.find { |n| n.type == :id } @group_ids << process(id).value else @@ -49,10 +54,10 @@ def clean(id) if id.is_a?(Array) id.map { |i| clean(i) } else - id.to_s.downcase.to_sym + id.to_s.symbolize.to_s end end end end end