diff --git a/README.rdoc b/README.rdoc index e00adbb7..8fb486ca 100644 --- a/README.rdoc +++ b/README.rdoc @@ -38,8 +38,8 @@ Windows from the command prompt (+cmd.exe+) If you don't have +rake+ installed, just run gem install rake -Any response for Ruby with a version number greater than 1.8 is fine (should be -around 1.8.6 or more). Any version of +rake+ will do. +Any response for Ruby with a version number greater than 1.9 is fine. Any version of ++rake+ will do. == Generating the Koans diff --git a/src/about_classes.rb b/src/about_classes.rb index 48c80543..9d8fae45 100644 --- a/src/about_classes.rb +++ b/src/about_classes.rb @@ -22,7 +22,7 @@ def test_instance_variables_can_be_set_by_assigning_to_them assert_equal __([]), fido.instance_variables fido.set_name("Fido") - assert_equal __(["@name"], [:@name]), fido.instance_variables + assert_equal __([:@name]), fido.instance_variables end def test_instance_variables_cannot_be_accessed_outside_the_class @@ -180,7 +180,7 @@ def test_inspect_provides_a_more_complete_string_version def test_all_objects_support_to_s_and_inspect array = [1,2,3] - assert_equal __("123", "[1, 2, 3]"), array.to_s + assert_equal __("[1, 2, 3]"), array.to_s assert_equal __("[1, 2, 3]"), array.inspect assert_equal __("STRING"), "STRING".to_s diff --git a/src/about_hashes.rb b/src/about_hashes.rb index 327bfc2a..47a33020 100644 --- a/src/about_hashes.rb +++ b/src/about_hashes.rb @@ -23,7 +23,7 @@ def test_accessing_hashes def test_accessing_hashes_with_fetch hash = { :one => "uno" } assert_equal __("uno"), hash.fetch(:one) - assert_raise(___(IndexError, KeyError)) do + assert_raise(___(KeyError)) do hash.fetch(:doesnt_exist) end diff --git a/src/about_iteration.rb b/src/about_iteration.rb index c0362173..faabd5d8 100644 --- a/src/about_iteration.rb +++ b/src/about_iteration.rb @@ -2,29 +2,8 @@ class AboutIteration < Neo::Koan - # -- An Aside ------------------------------------------------------ - # Ruby 1.8 stores names as strings. Ruby 1.9 and later stores names - # as symbols. So we use a version dependent method "as_name" to - # convert to the right format in the koans. We will use "as_name" - # whenever comparing to lists of methods. - - in_ruby_version("1.8") do - def as_name(name) - name.to_s - end - end - - in_ruby_version("1.9", "2", "3", "4") do - def as_name(name) - name.to_sym - end - end - - # Ok, now back to the Koans. - # ------------------------------------------------------------------- - def test_each_is_a_method_on_arrays - assert_equal __(true), [].methods.include?(as_name(:each)) + assert_equal __(true), [].methods.include?(:each) end def test_iterating_with_each diff --git a/src/about_scope.rb b/src/about_scope.rb index 4760a9ae..fc872a6c 100644 --- a/src/about_scope.rb +++ b/src/about_scope.rb @@ -73,7 +73,7 @@ def test_constants_can_be_looked_up_explicitly end def test_you_can_get_a_list_of_constants_for_any_class_or_module - assert_equal __(["Dog"], [:Dog]), Jims.constants + assert_equal __([:Dog]), Jims.constants assert Object.constants.size > _n_(10) end end diff --git a/src/about_strings.rb b/src/about_strings.rb index 69221f0a..20026a12 100644 --- a/src/about_strings.rb +++ b/src/about_strings.rb @@ -145,25 +145,12 @@ def test_you_can_get_a_substring_from_a_string def test_you_can_get_a_single_character_from_a_string string = "Bacon, lettuce and tomato" - assert_equal __(97, 'a'), string[1] - - # Surprised? - end - - in_ruby_version("1.8") do - def test_in_older_ruby_single_characters_are_represented_by_integers - assert_equal __(97, 'a'), ?a - assert_equal __(true, false), ?a == 97 - - assert_equal __(true), ?b == (?a + 1) - end + assert_equal __('a'), string[1] end - in_ruby_version("1.9", "2", "3", "4") do - def test_in_modern_ruby_single_characters_are_represented_by_strings - assert_equal __('a'), ?a - assert_equal __(false), ?a == 97 - end + def test_in_modern_ruby_single_characters_are_represented_by_strings + assert_equal __('a'), ?a + assert_equal __(false), ?a == 97 end def test_strings_can_be_split diff --git a/src/neo.rb b/src/neo.rb index 0985362a..6142281f 100644 --- a/src/neo.rb +++ b/src/neo.rb @@ -29,37 +29,19 @@ def before_ruby_version(version) Gem::Version.new(RUBY_VERSION) < Gem::Version.new(version) end -in_ruby_version("1.8") do - class KeyError < StandardError - end -end - # Standard, generic replacement value. -# If value19 is given, it is used in place of value for Ruby 1.9. -def __(value="FILL ME IN", value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def __(value="FILL ME IN") + value end # Numeric replacement value. -def _n_(value=999999, value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def _n_(value=999999) + value end # Error object replacement value. -def ___(value=FillMeInError, value19=:mu) - if RUBY_VERSION < "1.9" - value - else - (value19 == :mu) ? value : value19 - end +def ___(value=FillMeInError) + value end # Method name replacement. @@ -70,9 +52,7 @@ def ____(method=nil) end end - in_ruby_version("1.9", "2", "3", "4") do - public :method_missing - end + public :method_missing end class String