[rspec-users] cucumber is_admin? testing
aslak hellesoy
aslak.hellesoy at gmail.com
Wed Nov 23 10:22:05 EST 2011
On Wed, Nov 23, 2011 at 3:10 PM, Alex Whiteland <lists at ruby-forum.com> wrote:
> I don't know where to put this post,
Here: http://groups.google.com/group/cukes
> but theme of this more similar to
> my issue.
>
> I have trite signin system, like this:
>
>> ApplicationController:
> include SessionsHelper
>
> private
>
> helper_method :current_user
>
> def current_user
> @current_user ||= User.find(session[:user_id]) if session[:user_id]
> end
>
>
>> SessionsHelper:
> def is_admin?
> @current_user && @current_user.id == 1
> end
>
>
>> features/support/env.rb:
> World(SessionsHelper)
>
> So, if I test
>> is_admin?.should be_true
>
> it returns:
>
> expected nil to be true (RSpec::Expectations::ExpectationNotMetError)
> ./features/step_definitions/users/add_user.rb:23:in `/^I should
> signin$/'
> features/users/add_user.feature:13:in `And I should signin'
>
> But I signed in! Why? What's the way to test authentication system from
> scratch?
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
More information about the rspec-users
mailing list