GitHub User: hilary
The testing question is a valuable one. I am a behavior-driven development addict; Cucumber was the driving force for me to jump ship to Ruby, so I am using Cucumber and RSpec.
I used this railscast as a guide for an app I'm moving to Rails, following the advice to implement auth oneself when new to Rails rather than relying on a gem. Good advice (if sometimes painful!) The sessions controller code worked fine for me with live testing but login tests of bad data generated a missing template error.
Looking at it again, it looked to me as if the create method of the sessions controller code is not asking for the right template when the user enters the wrong info. The error message indicated that it was looking for a sessions/create template, which made sense to me, as the else branch does not have a render statement (and so it defaults to rendering sessions with the method it is in?). To solve the problem, I added render "new" after setting the flash, as in:
member = Member.find_by_primary_email(params[:primary_email])
if member && member.authenticate(params[:password])
session[:member_id] = member.id
redirect_to root_url, notice: t('notices.logged_in')
flash.now.alert = t('errors.invalid_login')
Now my sign in features are all passing, yay!
Sorry to be so long-winded, but I'm really new to Rails, so I'm wondering what I got right and what I got wrong in my analysis and solution.
I also wanted to say thank you for RailsCasts. Your service has been invaluable to me as I retool my skills.