Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4889

Show
Ignore:
Timestamp:
09/01/06 01:12:30 (4 years ago)
Author:
madrobby
Message:

script.aculo.us: Add assertRespondsTo and shouldRespondTo assertions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/scriptaculous/CHANGELOG

    r4863 r4889  
    11*SVN* 
     2 
     3* Add assertRespondsTo and shouldRespondTo assertions 
    24 
    35* Add experimental alternate syntax for unit tests (Behaviour Driven Development-style) 
  • spinoffs/scriptaculous/src/unittest.js

    r4867 r4889  
    368368    catch(e) { this.error(e); }  
    369369  }, 
     370  assertRespondsTo: function(method, obj) { 
     371    var message = arguments[2] || 'assertRespondsTo'; 
     372    try { 
     373      (obj[method] && typeof obj[method] == 'function') ? this.pass() :  
     374      this.fail(message + ": object doesn't respond to [" + method + "]"); } 
     375    catch(e) { this.error(e); } 
     376  }, 
    370377  assertReturnsTrue: function(method, obj) { 
    371378    var message = arguments[2] || 'assertReturnsTrue'; 
     
    478485     
    479486    shouldBe:        'assertReturnsTrue', 
    480     shouldNotBe:     'assertReturnsFalse' 
     487    shouldNotBe:     'assertReturnsFalse', 
     488    shouldRespondTo: 'assertRespondsTo' 
    481489  }; 
    482490  Test.BDDMethods = {}; 
  • spinoffs/scriptaculous/test/unit/bdd_test.html

    r4867 r4889  
    5757  }, 
    5858   
    59   'should provide extensions to tie in isSomething object methods': function(){ 
     59  'should provide extensions to tie in isSomething and respondsTo object methods': function(){ 
    6060    Object.extend(testObj, Test.BDDMethods); 
    6161     
    6262    testObj.shouldBe('nice'); 
    6363    testObj.shouldNotBe('broken'); 
     64     
     65    testObj.shouldRespondTo('isNice'); 
     66    testObj.shouldRespondTo('isBroken'); 
    6467  }, 
    6568   
  • spinoffs/scriptaculous/test/unit/element_test.html

    r4785 r4889  
    199199      benchmark(function(){ 
    200200        Element.childrenWithClassName("Container", "firstClass")  
    201       },1,'Element.childrenWithClassName'); 
     201      },1000,'Element.childrenWithClassName'); 
    202202     
    203203      // ... and that none that don't exist have been found. 
  • spinoffs/scriptaculous/test/unit/unittest_test.html

    r4867 r4889  
    7272      assertNotEqual([],[]); 
    7373      assertNotEqual([],{}); 
     74    }}, 
     75     
     76    testAssertRespondsTo: function() { with(this) { 
     77      assertRespondsTo('isNice', testObj); 
     78      assertRespondsTo('isBroken', testObj); 
    7479    }}, 
    7580