Login_With

34 views
Skip to first unread message

Matias

unread,
Aug 12, 2011, 1:07:58 PM8/12/11
to Steak
Im using rails 2.3.12 with Devise.

I create a helper:

def login_with(user)
visit "/users/sign_in"
fill_in "user_login", :with => user.email
fill_in "user_password", :with => user.password
click_on "Acceder"
end

And an acceptance test with:

let :user do
Factory.create :user
end

background do
login_with user
end

scenario "Promotor should see his money in the home panel" do
should_be_on user_panel
end

But the fail because the page is still users/sign_in. But the
misterious is that looking at page.body I doesn't see any error.

Boris Barroso

unread,
Aug 12, 2011, 1:38:12 PM8/12/11
to ste...@googlegroups.com
When you use devise with rspec and steak you should make some changes in your configuration.
this is for rails3
https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29

2011/8/12 Matias <tute....@gmail.com>



--
Boris Barroso
Senior Ruby on Rails, Javascript developer


Matias

unread,
Aug 12, 2011, 2:35:25 PM8/12/11
to Steak
That's only works for controllers, not acceptance test.

On 12 ago, 14:38, Boris Barroso <boriscy...@gmail.com> wrote:
> When you use devise with rspec and steak you should make some changes in
> your configuration.
> this is for rails3https://github.com/plataformatec/devise/wiki/How-To:-Controllers-and-...
>
> 2011/8/12 Matias <tute.uni...@gmail.com>
>
>
>
>
>
>
>
>
>
> > Im using rails 2.3.12 with Devise.
>
> > I create a helper:
>
> >  def login_with(user)
> >    visit "/users/sign_in"
> >    fill_in "user_login",     :with => user.email
> >    fill_in "user_password", :with => user.password
> >    click_on "Acceder"
> >  end
>
> > And an acceptance test with:
>
> >  let :user do
> >    Factory.create :user
> >  end
>
> >  background do
> >    login_with user
> >  end
>
> >  scenario "Promotor should see his money in the home panel" do
> >    should_be_on user_panel
> >  end
>
> > But the fail because the page is still users/sign_in. But the
> > misterious is that looking at page.body I doesn't see any error.
>
> --
> Boris Barroso
> *Senior Ruby on Rails, Javascript developer*

Luismi Cavallé

unread,
Aug 12, 2011, 3:46:08 PM8/12/11
to ste...@googlegroups.com
Devise (or any other authentication library) shouldn't be an issue here. Problem should be somewhere else. For instance, are you sure "user.password" returns the password of the user?

-- Luismi

Matias

unread,
Aug 12, 2011, 4:17:26 PM8/12/11
to Steak
No, thats was my mistake. But even fixing that passing the real
password I still doesn't log_in. The weird thing is that I don't catch
any error when I look the page.body after click_button "Acceder".

Matias

unread,
Aug 12, 2011, 5:42:14 PM8/12/11
to Steak
Why is so complicated to test with this gems!?
Reply all
Reply to author
Forward
0 new messages