Restful-Authentication Rspec Failure Rails 2.0.2

21 views
Skip to first unread message

dhf...@gmail.com

unread,
Dec 30, 2007, 4:28:20 PM12/30/07
to Ruby on Rails: Talk
I am trying the Restful-Authentication (latest version, downloaded
today) and upon running the generator, doing the migration, prepping
the test system and putting the resources in routes.rb I get a Rspec
test failure:

'SessionsController logins and redirects' FAILED
expected not nil, got nil

routes.rb has:
map.resources :users
map.resources :sessions

nothing else was changed or done. there is only one other controller/
model in the system and rspec tested it with no errors.

Is this a known bug? Should I just be using something else? I have
used this several times on 1.2.6 with no problem.

Thanks

Don French

Robert Walker

unread,
Dec 30, 2007, 8:14:17 PM12/30/07
to Ruby on Rails: Talk
Check your routes again.

You are showing:
> routes.rb has:
> map.resources :users
> map.resources :sessions

It should be:
map.resources :users
map.resource :session

Note the singular form for session. Each user can only have one
session at a time so it's singular.

dhf...@gmail.com

unread,
Dec 31, 2007, 3:57:23 PM12/31/07
to Ruby on Rails: Talk
I tried that before and just did. Same error.

code around the failure is:
it 'logins and redirects' do
post :create, :login => 'quentin', :password => 'test'
session[:user].should_not be_nil # -> Error is on this line
response.should be_redirect
end

Error is:
1)
'SessionsController logins and redirects' FAILED
expected not nil, got nil
/Users/dhf/NetBeansProjects/snrbad/spec/controllers/
sessions_controller_spec.rb:12:

Finished in 0.145385 seconds

9 examples, 1 failure

Rick Olson

unread,
Dec 31, 2007, 5:14:22 PM12/31/07
to rubyonra...@googlegroups.com
On Dec 31, 2007 12:57 PM, dhf...@gmail.com <dhf...@gmail.com> wrote:
>
> I tried that before and just did. Same error.
>
> code around the failure is:
> it 'logins and redirects' do
> post :create, :login => 'quentin', :password => 'test'
> session[:user].should_not be_nil # -> Error is on this line
> response.should be_redirect
> end
>
> Error is:
> 1)
> 'SessionsController logins and redirects' FAILED
> expected not nil, got nil
> /Users/dhf/NetBeansProjects/snrbad/spec/controllers/
> sessions_controller_spec.rb:12:
>
> Finished in 0.145385 seconds
>
> 9 examples, 1 failure

Changes in your app can cause these test failures. I very recently
used the rspec version when it was committed and had no problems.
It's only a restful_auth issue if it does this on a brand new app.
Please do send a patch if you uncover a bug.

--
Rick Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

Bryan Larsen

unread,
Dec 31, 2007, 6:17:35 PM12/31/07
to Ruby on Rails: Talk

> It's only a restful_auth issue if it does this on a brand new app.

It does this to me on a brand new app.

> Please do send a patch if you uncover a bug.

--- functional_spec.rb.orig 2007-12-31 17:33:13.000000000 -0500
+++ functional_spec.rb 2007-12-31 18:13:20.000000000 -0500
@@ -9,20 +9,20 @@

it 'logins and redirects' do
post :create, :login => 'quentin', :password => 'test'
- session[:<%= file_name %>].should_not be_nil
+ session[:<%= file_name %>_id].should_not be_nil
response.should be_redirect
end

it 'fails login and does not redirect' do
post :create, :login => 'quentin', :password => 'bad password'
- session[:<%= file_name %>].should be_nil
+ session[:<%= file_name %>_id].should be_nil
response.should be_success
end

it 'logs out' do
login_as :quentin
get :destroy
- session[:<%= file_name %>].should be_nil
+ session[:<%= file_name %>_id].should be_nil
response.should be_redirect
end

Rick Olson

unread,
Dec 31, 2007, 9:06:03 PM12/31/07
to rubyonra...@googlegroups.com

Oh awesome, someone gets reprimanded for not testing before committing
:) Thanks.

dhf...@gmail.com

unread,
Jan 1, 2008, 12:35:54 AM1/1/08
to Ruby on Rails: Talk
Thanks. I thought I had tried everything before I submitted the
problem. I even had done but did not mention what Rick had recommended
and it failed also.

When will then plugin be updated so I do not have to make the changes
on each project?

Don French

On Dec 31, 4:06 pm, "Rick Olson" <technowee...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages