Skip to content

Commit

Permalink
Fixed :each VS "each" conflict in method list inclusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Dec 4, 2011
1 parent 6001bec commit 271dff2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/about_iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,29 @@

class AboutIteration < EdgeCase::Koan

# -- An Aside ------------------------------------------------------
# Ruby 1.8 stores names as strings. Ruby 1.9 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") do
def as_name(name)
name.to_sym
end
end

# Ok, now back to the Koans.
# -------------------------------------------------------------------

def test_each_is_a_method_on_arrays
[].methods.include?("each")
assert_equal __(true), [].methods.include?(as_name(:each))
end

def test_iterating_with_each
Expand Down

0 comments on commit 271dff2

Please sign in to comment.