class Object
Public Instance Methods
assert() { || ... }
click to toggle source
# File lib/assertions.rb, line 1 def assert &block begin raise AssertionError.new(&block) unless yield print "\u2713".green rescue AssertionError => e print "x".red + " " + e.message raise BlockError end end
assertRaise() { || ... }
click to toggle source
# File lib/assertions.rb, line 11 def assertRaise &block begin begin yield rescue Exception => e print "\u2713".green return end raise AssertExceptionError.new(&block) rescue AssertExceptionError => e puts "x".red + " " + e.message raise BlockError end end
cleanup(&func)
click to toggle source
# File lib/adispec.rb, line 56 def cleanup(&func) Section::lastspec.push_cleanup(func) end
describe(desc, &func)
click to toggle source
# File lib/adispec.rb, line 8 def describe(desc, &func) sp = Section.new(desc) pad = [' '] * Section::specstack.length * '' puts puts pad + desc.blue + ":" func.call Section::specstack.pop if Section::specstack.empty? puts Suite::stacks.pop Suite.inc_tests sp.tests Suite.inc_passes sp.passes Suite.inc_fails sp.fails puts "Result: #{Suite::tests} ran, "\ "#{Suite::passes.to_s.green} "\ "#{"passed".green}, "\ "#{Suite::fails.to_s.red} "\ "#{"failed".red}" if Suite::stacks.empty? else Section::lastspec.inc_tests sp.tests Section::lastspec.inc_passes sp.passes Section::lastspec.inc_fails sp.fails end end
it(desc, &func)
click to toggle source
# File lib/adispec.rb, line 33 def it(desc, &func) pad = [' '] * Section::specstack.length * '' print pad + desc + ": " Section::lastspec.inc_tests begin Section::specstack.each do |spec| spec.run_setups end func.call Section::lastspec.run_cleanups rescue BlockError Section::lastspec.inc_fails puts return end Section::lastspec.inc_passes puts end
setup(&func)
click to toggle source
# File lib/adispec.rb, line 52 def setup(&func) Section::lastspec.push_setup(func) end