[Ruby] Testing Models in Rails

James Moore banshee at banshee.com
Thu Jul 26 15:30:20 PDT 2007


Just stub out the call to create that save's going to do eventually?

  def test_do_stuff
    stuff = User.new :name => 'L Richie', :current_mood => 'All night long'
    stuff.stubs(:create).returns(true) # Mocha
    def stuff.create; true; end # Or plain Ruby
    assert stuff.save
    assert_good_things_happened stuff
  end

(Untested, just an idea)

 - James



More information about the Ruby mailing list