From 9e6c8fa3bf5f5db2252022edcbbe6092ff69cb74 Mon Sep 17 00:00:00 2001 From: "Fabio M. Costa" Date: Sun, 21 Mar 2010 16:17:42 -0300 Subject: [PATCH] adding specs for the toString method on a new class --- 1.3public/Class/Class.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/1.3public/Class/Class.js b/1.3public/Class/Class.js index c1751ed..aa157e3 100644 --- a/1.3public/Class/Class.js +++ b/1.3public/Class/Class.js @@ -24,6 +24,10 @@ var Animal = new Class({ say: function(){ return 'animal:say:' + this.name; + }, + + toString: function(){ + return this.name; } }); @@ -206,8 +210,8 @@ describe('Class creation', { value_of(spot.say()).should_be('NEW:animal:say:spot'); value_of(rover.say()).should_be('NEW:animal:say:rover'); - } - + }, + //We might attempt to add support for the following at a later date /* @@ -234,6 +238,11 @@ describe('Class creation', { value_of(rover.say()).should_be('NEW:animal:say:rover'); } */ + + "should overwrite the toString method": function(){ + var animal = new Animal('dolphin'); + value_of(animal + '').should_be('dolphin'); + } });