I'm a rails noob, still working on my first test and seeing strange behavior - the state of the model that is changed during the method being tested is appearing to not be saved. I'm assuming I'm missing something basic here...
My Buzzuser model is listed below. In the migration that adds this table, I identify a column for level.
class Buzzuser < ActiveRecord::Base
def initialize super @level = 0 end
def promote @level += 1 puts "new level = ", @level
end end
Here's the test:
class BuzzuserTest < ActiveSupport::TestCase fixtures :ranks
def test_promote bu = Buzzuser.new bu.promote assert_equal(1, bu.level, "buzzuser level wasn't incremented") end end
The output from the test, in the console, prints out (among other stuff):
new level = 1
But when it returns back to the test, the assertion fails. Why?
Thanks