# Salted Hash Login Generator problem

**URL:** <https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737>\
**Category:** Rails\
**Created:** [April 13, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737 "2006-04-13T16:33:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [April 13, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737/1 "2006-04-13T16:33:02Z")

</div>

Im trying to install salted and get errors when running the rake test…

/usr/bin/ruby1.8 -Ilib:test  
“/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake\_test\_loader .rb”  
“test/unit/localization\_test.rb” “test/unit/user\_test.rb”  
Loaded suite  
/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake\_test\_loader  
Started  
…F…E  
Finished in 0.108794 seconds.

1. Failure:  
test\_auth(UserTest) [./test/unit/user\_test.rb:9]:  
 expected but was  
\<#\<User:0xb75d7210  
@attributes=  
{“salt”=\>“7f8b036f9b647d46d22abdbfc8113f44a88f9889”,  
“delete\_after”=\>nil,  
“security\_token”=\>nil,  
“role”=\>nil,  
“lastname”=\>nil,  
“firstname”=\>nil,  
“id”=\>“1000001”,  
“deleted”=\>“0”,  
“token\_expiry”=\>nil,  
“verified”=\>“1”,  
“salted\_password”=\>“ef94c16f6c124a4e84cc215c164767bfa25f6e92”,  
“login”=\>“bob”,  
“email”=\>“removed\_email\_address@domain.invalid”}\>\>.

2. Error:  
test\_passwordchange(UserTest):  
NoMethodError: You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.change\_password  
./test/unit/user\_test.rb:17:in `test\_passwordchange’

14 tests, 27 assertions, 1 failures, 1 errors  
rake aborted!  
Command failed with status (1): [/usr/bin/ruby1.8 -Ilib:test  
"/usr/lib/ruby…]

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [April 13, 2006, 5:01pm UTC](https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737/2 "2006-04-13T17:01:08Z")

</div>

Hi Rob,

I just encountered the exact same problem. The test code that is failing  
is this:  
assert\_equal @bob, User.authenticate(“bob”, “atest”)

But I could not find anywhere where @bob was being set. The only thing I  
could think of was that  
perhaps the author used some sort of extension that would generate these  
objects from the fixtures. There is another place where an @longbob is  
assumed to exist as well.

I haven’t had a chance to track this down any farther, so I changed the  
line to this:  
assert\_not\_nil User.authenticate(“bob”, “atest”)

to get past the first error. Then I went to bed, leaving the other error  
intact while I did a little more research on this. Does anyone else know  
anything about this? It woud look like the author was able to get an  
@bob and @longbob generated simply from the fixture. Is there a way to  
do this?

John Q.

Rob B. wrote:

> Im trying to install salted and get errors when running the rake test…
> 
> /usr/bin/ruby1.8 -Ilib:test  
> “/usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake\_test\_loader .rb”  
> “test/unit/localization\_test.rb” “test/unit/user\_test.rb”  
> Loaded suite  
> /usr/lib/ruby/gems/1.8/gems/rake-0.7.0/lib/rake/rake\_test\_loader  
> Started  
> …F…E  
> Finished in 0.108794 seconds.
> 
> 1. Failure:  
> test\_auth(UserTest) [./test/unit/user\_test.rb:9]:  
> expected but was  
> \<#\<User:0xb75d7210  
> @attributes=  
> {“salt”=\>“7f8b036f9b647d46d22abdbfc8113f44a88f9889”,  
> “delete\_after”=\>nil,  
> “security\_token”=\>nil,  
> “role”=\>nil,  
> “lastname”=\>nil,  
> “firstname”=\>nil,  
> “id”=\>“1000001”,  
> “deleted”=\>“0”,  
> “token\_expiry”=\>nil,  
> “verified”=\>“1”,  
> “salted\_password”=\>“ef94c16f6c124a4e84cc215c164767bfa25f6e92”,  
> “login”=\>“bob”,  
> “email”=\>“removed\_email\_address@domain.invalid”}\>\>.
> 
> 2. Error:  
> test\_passwordchange(UserTest):  
> NoMethodError: You have a nil object when you didn’t expect it!  
> The error occured while evaluating nil.change\_password  
> ./test/unit/user\_test.rb:17:in `test\_passwordchange’
> 
> 14 tests, 27 assertions, 1 failures, 1 errors  
> rake aborted!  
> Command failed with status (1): [/usr/bin/ruby1.8 -Ilib:test  
> "/usr/lib/ruby…]

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [April 13, 2006, 7:02pm UTC](https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737/3 "2006-04-13T19:02:37Z")

</div>

John Q. wrote:

> I just encountered the exact same problem. The test code that is failing  
> is this:  
> assert\_equal @bob, User.authenticate(“bob”, “atest”)
> 
> But I could not find anywhere where @bob was being set. The only thing I  
> could think of was that  
> perhaps the author used some sort of extension that would generate these  
> objects from the fixtures. There is another place where an @longbob is  
> assumed to exist as well.

To my knowledge these tests have never worked. A couple of the unit  
tests fail out of the box, but all the functional tests fail. Perhaps  
they worked on Rails 0.5 or something, I don’t know. I first looked at  
them at around Rails 0.12.

On the plus side, even though the tests fail, the code itself seems to  
work.

When I was looking at this a few months ago I was able to make both the  
unit and functional tests pass with some effort and to improve the  
coverage of the tests. At the time I was new to ruby and rails, so I  
ended up learning quite a bit in this exercise, but if I knew then what  
I know now, I would have moved to acts\_as\_authenticated weeks earlier.

Almost everything in rails just works or is within a couple of  
configuration steps from working. That is not the case for these tests.

–

Ray

---

<div class="post-metadata">

**Author:** ![robtotheb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@robtotheb](https://www.ruby-forum.com/u/robtotheb)\
**Post date:** [April 13, 2006, 10:12pm UTC](https://www.ruby-forum.com/t/salted-hash-login-generator-problem/57737/4 "2006-04-13T22:12:22Z")

</div>

John Q. wrote:

> Hi Rob,
> 
> I just encountered the exact same problem. The test code that is failing  
> is this:  
> assert\_equal @bob, User.authenticate(“bob”, “atest”)

…

> > 14 tests, 27 assertions, 1 failures, 1 errors  
> > rake aborted!  
> > Command failed with status (1): [/usr/bin/ruby1.8 -Ilib:test  
> > "/usr/lib/ruby…]

If I remember right it has to do with some changes to the Rails test  
code, about the way it loads fixtures. I think it was a change from  
0.14 to 1.0 but I don’t recall exactly.

I’ll look into it to see what I did, but I know I went into the tests on  
my installation of SHLG and did some fiddling to get them up to date,  
for my own satisfaction.

Jeff C.man
