In order to make options handling a bit easier I''ve mixed this method
into class Hash
def value_to_a(key, default = [])
if value = self[key]
puts "#{value.inspect}:#{value.class}, #{value.kind_of?(Array)}"
value.kind_of?(Array) ? value : [ value ]
else
default
end
end
When I run my unit tests separately they work without a hitch. But when
I run all my tests using rake, the result boggles my mind. This test
fails
def test_value_to_a_array
options = { ''mykey'' => [ ''thevalue'',
''anothervalue'' ] }
assert_equal(
[''thevalue'', ''anothervalue''],
options.value_to_a(''mykey''))
end
Even though the debug output indicates that value.class is Array,
value.kind_of?(Array) returns false. Specifically, this happens, when I
ran this particular test in conjunction with another test case where I
check some extensions of the Array class. Apparently, Ruby is doing
something to the class hierarchy that''s beyond me.
Michael
--
Michael Schuerig Life is just as deadly
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org
As it looks
http://www.schuerig.de/michael/ --Richard Thompson, Sibella