class Shindo::Tests
def test(description, tags = [], &block)
def test(description, tags = [], &block) @description_stack.push(description) @tag_stack.push([*tags]) # if the test includes tags and discludes ^tags, evaluate it if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) && (@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?) if block_given? for before in @befores.flatten.compact before.call end @annals.start begin success = instance_eval(&block) @annals.stop rescue => error success = false file, line, method = error.backtrace.first.split(':') if method method << "in #{method[4...-1]} " # get method from "in `foo'" else method = '' end method << "! #{error.message} (#{error.class})" @annals.stop @annals.unshift(:file => file, :line => line.to_i, :method => method) end @success = @success && success if success green_line("+ #{full_description}") else red_line("- #{full_description}") if STDOUT.tty? prompt(&block) end end for after in @afters.flatten.compact after.call end else yellow_line("* #{full_description}") end else print_line("_ #{full_description}") end @tag_stack.pop @description_stack.pop end