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
8 changed files with 38 additions and 42 deletions

View File

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

View File

@@ -95,21 +95,6 @@ class AboutJavaInterop < EdgeCase::Koan
assert_equal __, java_array.toString.is_a?(java.lang.String)
end
def test_some_ruby_objects_can_be_coerced_to_java
assert_equal __, "ruby string".to_java.class
assert_equal __, 1.to_java.class
assert_equal __, 9.32.to_java.class
assert_equal __, false.to_java.class
end
def test_some_ruby_objects_can_NOT_be_coerced_to_java
[[], {}, Object.new].each do |ruby_object|
assert_raise(___) do
ruby_object.to_java_class
end
end
end
def test_java_collections_are_enumerable
java_array = java.util.ArrayList.new
java_array << "one" << "two" << "three"

View File

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

View File

@@ -93,16 +93,29 @@ module EdgeCase
end
def colorize(string, color_value)
if ENV['NO_COLOR']
string
else
if use_colors?
color(color_value) + string + color(COLORS[:clear])
else
string
end
end
def color(color_value)
"\e[#{color_value}m"
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
class Sensei

View File

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

View File

@@ -95,21 +95,6 @@ class AboutJavaInterop < EdgeCase::Koan
assert_equal __(false), java_array.toString.is_a?(java.lang.String)
end
def test_some_ruby_objects_can_be_coerced_to_java
assert_equal __(Java::JavaLang::String), "ruby string".to_java.class
assert_equal __(Java::JavaLang::Long), 1.to_java.class
assert_equal __(Java::JavaLang::Double), 9.32.to_java.class
assert_equal __(Java::JavaLang::Boolean), false.to_java.class
end
def test_some_ruby_objects_can_NOT_be_coerced_to_java
[[], {}, Object.new].each do |ruby_object|
assert_raise(___(NoMethodError)) do
ruby_object.to_java_class
end
end
end
def test_java_collections_are_enumerable
java_array = java.util.ArrayList.new
java_array << "one" << "two" << "three"

View File

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

View File

@@ -93,16 +93,29 @@ module EdgeCase
end
def colorize(string, color_value)
if ENV['NO_COLOR']
string
else
if use_colors?
color(color_value) + string + color(COLORS[:clear])
else
string
end
end
def color(color_value)
"\e[#{color_value}m"
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
class Sensei