5 Commits

Author SHA1 Message Date
Jim Weirich
d3ce64a768 Updatd exception koan to be clearer about StandardError VS RuntimeError 2010-11-29 09:02:22 -05:00
Luke Pearce
9291f534c6 Fixed exceptions typo 2010-11-29 13:24:40 +00:00
Jim Weirich
71f670ac1d Disabled colored output on windows. 2010-10-21 07:05:06 -04:00
Jim Weirich
1864c9c346 Updated koans for about_symbols fix 2010-10-21 07:04:54 -04:00
Jim Weirich
cfd5b6bbe1 Fixed test_symbols_with_spaces_can_be_built method name collision. 2010-10-21 07:02:10 -04:00
6 changed files with 38 additions and 12 deletions

View File

@@ -22,8 +22,8 @@ class AboutExceptions < EdgeCase::Koan
assert_equal __, result assert_equal __, result
assert ex.is_a?(___), "Failure message." assert_equal __, ex.is_a?(StandardError), "Should be a Standard Error"
assert ex.is_a?(___), "Failure message." assert_equal __, ex.is_a?(RuntimeError), "Should be a Runtime Error"
assert RuntimeError.ancestors.include?(StandardError), assert RuntimeError.ancestors.include?(StandardError),
"RuntimeError is a subclass of StandardError" "RuntimeError is a subclass of StandardError"

View File

@@ -53,7 +53,7 @@ class AboutSymbols < EdgeCase::Koan
assert_equal symbol, __.to_sym assert_equal symbol, __.to_sym
end end
def test_symbols_with_spaces_can_be_built def test_symbols_with_interpolation_can_be_built
value = "and" value = "and"
symbol = :"cats #{value} dogs" symbol = :"cats #{value} dogs"

View File

@@ -93,16 +93,29 @@ module EdgeCase
end end
def colorize(string, color_value) def colorize(string, color_value)
if ENV['NO_COLOR'] if use_colors?
string
else
color(color_value) + string + color(COLORS[:clear]) color(color_value) + string + color(COLORS[:clear])
else
string
end end
end end
def color(color_value) def color(color_value)
"\e[#{color_value}m" "\e[#{color_value}m"
end end
def use_colors?
return false if ENV['NO_COLOR']
if ENV['ANSI_COLOR'].nil?
! using_windows?
else
ENV['ANSI_COLOR'] =~ /^(t|y)/i
end
end
def using_windows?
File::ALT_SEPARATOR
end
end end
class Sensei class Sensei

View File

@@ -22,8 +22,8 @@ class AboutExceptions < EdgeCase::Koan
assert_equal __(:exception_handled), result assert_equal __(:exception_handled), result
assert ex.is_a?(___(StandardError)), "Failure message." assert_equal __(true), ex.is_a?(StandardError), "Should be a Standard Error"
assert ex.is_a?(___(RuntimeError)), "Failure message." assert_equal __(true), ex.is_a?(RuntimeError), "Should be a Runtime Error"
assert RuntimeError.ancestors.include?(StandardError), # __ assert RuntimeError.ancestors.include?(StandardError), # __
"RuntimeError is a subclass of StandardError" "RuntimeError is a subclass of StandardError"

View File

@@ -53,7 +53,7 @@ class AboutSymbols < EdgeCase::Koan
assert_equal symbol, __("cats and dogs").to_sym assert_equal symbol, __("cats and dogs").to_sym
end end
def test_symbols_with_spaces_can_be_built def test_symbols_with_interpolation_can_be_built
value = "and" value = "and"
symbol = :"cats #{value} dogs" symbol = :"cats #{value} dogs"

View File

@@ -93,16 +93,29 @@ module EdgeCase
end end
def colorize(string, color_value) def colorize(string, color_value)
if ENV['NO_COLOR'] if use_colors?
string
else
color(color_value) + string + color(COLORS[:clear]) color(color_value) + string + color(COLORS[:clear])
else
string
end end
end end
def color(color_value) def color(color_value)
"\e[#{color_value}m" "\e[#{color_value}m"
end end
def use_colors?
return false if ENV['NO_COLOR']
if ENV['ANSI_COLOR'].nil?
! using_windows?
else
ENV['ANSI_COLOR'] =~ /^(t|y)/i
end
end
def using_windows?
File::ALT_SEPARATOR
end
end end
class Sensei class Sensei