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
@level = 0
@level += 1
puts "new level = ", @level
Here's the test:
class BuzzuserTest < ActiveSupport::TestCase
bu = Buzzuser.new
assert_equal(1, bu.level, "buzzuser level wasn't incremented")
The output from the test, in the console, prints out (among other
new level =
But when it returns back to the test, the assertion fails. Why?