Trivial, right?
class Foo < Array def self.bar other = new other << 'bar' other end def self.baz other = new other << 'baz' other end def bar other = clone other.unshift 'bar' other end def baz other = clone other.unshift 'baz' other end end
The to_s criterion fails because 1.9 has changed the way Array#to_s . Change this for compatibility:
Foo.baz.bar.to_s.should == ['bar', 'baz'].to_s
I want a cake.
BTW - metaprogramming here would reduce code size and greatly increase flexibility:
class Foo < Array def self.method_missing(message, *args) other = new other << message.to_s other end def method_missing(message, *args) other = clone other.unshift message.to_s other end end
source share