Re: [rspec-users] Mocking Access Control

2007-07-27 Thread Courtenay
On 7/27/07, Justin Williams <[EMAIL PROTECTED]> wrote: > Thanks for the help. > You're welcome > I think I'm getting closer. I'm still not getting a redirect. I > still think it's the same reason though. I say this because when I > modify the last line of my spec to be render_template("index")

Re: [rspec-users] Mocking Access Control

2007-07-27 Thread Justin Williams
Thanks for the help. I think I'm getting closer. I'm still not getting a redirect. I still think it's the same reason though. I say this because when I modify the last line of my spec to be render_template("index") instead of redirect, it says that it renders the login template. Am I putting t

Re: [rspec-users] Mocking Access Control

2007-07-26 Thread Courtenay
For starters, refactor your user<-->roles interaction. class User def has_role?(name) role = Role.find_by_name(name) roles.include?(role) end end Trust me, this will make things much easier to spec, and later, to scale. Also, it keeps the DB-specific stuff ("find") in the model, wh

Re: [rspec-users] Mocking Access Control

2007-07-26 Thread Justin Williams
I've done some more work on the specs, and it seems that my mocks aren't pushing in the roles array associated with current_user. describe UsersController do before(:each) do @user = mock_model(User, :id => 1, :email => '[EMAIL PROTECTED]', :password => 'teamup' )

Re: [rspec-users] Mocking Access Control

2007-07-24 Thread Justin Williams
On 7/24/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > Would you please post the code for the actions as well? def login if request.post? begin session[:user] = User.authenticate(params[:login][:email], params[:login][:password]).id if current_user.roles.include?(Role.find_by_title

Re: [rspec-users] Mocking Access Control

2007-07-24 Thread David Chelimsky
On 7/24/07, Justin Williams <[EMAIL PROTECTED]> wrote: > I'm trying to jump on the TDD/BDD bandwagon, but am having trouble > understanding how i should mock my user. The user has a habtm > relationship to a roles model (acl_system2 plugin), but I'm not sure > how to tell rspec about a model. > >

[rspec-users] Mocking Access Control

2007-07-24 Thread Justin Williams
I'm trying to jump on the TDD/BDD bandwagon, but am having trouble understanding how i should mock my user. The user has a habtm relationship to a roles model (acl_system2 plugin), but I'm not sure how to tell rspec about a model. My code: describe UsersController do integrate_views before(