Hello folks, this is the first time I’ve written to this forum. If
there’s already a topic on this, forgive me but the search isn’t working
I seem to have a problem validating confirmation of a password. The
first two snippets are some model code and some test code that work just
class Challenge < ActiveRecord::Base
class ChallengeTest < Test::Unit::TestCase
c = Challenge.new
c.title = c.title_confirmation = “some random title”
c.body = “some body text”
$ ruby test/unit/challenge_test.rb
Loaded suite test/unit/challenge_test
Finished in 0.521554 seconds.
2 tests, 3 assertions, 0 failures, 0 errors
the second snippet seems identical, but it yields a failed assertion:
class User < ActiveRecord::Base
class UserTest < Test::Unit::TestCase
u = User.new( :username => “newbob”,
:password => “newpassword”,
:email => “[email protected]” )
u.password_confirmation = “newpassword”
assert u.save #(this is line 17)
$ ruby test/unit/user_test.rb
Loaded suite test/unit/user_test
Finished in 0.343036 seconds.
is not true.
2 tests, 2 assertions, 1 failures, 0 errors
Can anyone see an error i can’t? For the life of me, I can’t seem to
figure out why the two would behave any differently. I can provide more
(surrounding) code if necessary, but it was already getting pretty long
. . .
For the record, I ran into this while trying to follow the tutorial at