mirror of
https://github.com/edgecase/ruby_koans.git
synced 2026-04-15 07:23:19 -04:00
Compare commits
5 Commits
more_jruby
...
rubykoans-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3ce64a768 | ||
|
|
9291f534c6 | ||
|
|
71f670ac1d | ||
|
|
1864c9c346 | ||
|
|
cfd5b6bbe1 |
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user