Salted Hash Login Generator problem


#1

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…]


#2

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…]


#3

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


#4

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