wtf?
maybe I post an initiate letter here, and then find a way to write you?
> Started here
Hi!
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?
> that is added to cucumber's world does not have access to your
> application
> controller's @current_user variable.
So, I understand this. But how I can avoid this defect?
If I paste def is_admin? into application_controller near current_user
method, I wouldn't can World(ApplicationController). If I copy
current_user code to sessions_helper, then session[:user_id] wouldn't
work.
Regards, Alex Whiteland
> end
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users