Forum: RSpec [cucumber] Cucumber and restful_authentication

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tadatoshi T. (Guest)
on 2009-04-10 03:09
(Received via mailing list)
Hi,

I have just started to use Cucumber.
I'm struggling to use Cucumber on the feature that is available only to
the logged in user.

Could anybody provide the codes that need to be added?


The sites I found by Google search don't give clear information about
what to do.
The ones I found are:

http://stackoverflow.com/questions/679928?sort=new...
http://stackoverflow.com/questions/382473/how-do-i...
http://blog.andrew.premdas.org/articles/2008/10/12...


The step I added is:

Given /^I am logged in$/ do
  User.create!( :first_name => 'quire',
                :last_name => 'smith',
                :login => 'quire',
                :email => 'removed_email_address@domain.invalid',
                :password => 'test',
                :password_confirmation => 'test' )
  post "/login", :login => 'quire', :password => 'test'
end

By the way, in routes.rb, I'm setting the following as described in
restful_authentication:

map.login '/login', :controller => 'sessions', :action => 'new'

Without login_required and the step above, the Cucumber scenario was
successfully run. But after I put login_required and the step above,
Cucumber cannot locate a field (its value is filled in text field).

Thank you in advance.

Tadatoshi
Andrew P. (Guest)
on 2009-04-13 23:42
(Received via mailing list)
You could look at fbrp (http://github.com/diabolo/fbrp/tree/master)
which
has lots of tests like this.
You could add a debug statement when you visit a page that you actually
have
to be logged in, to see if you actually are logged in.

I suspect of the top of my head that you are not logged in when you have
done your post, as your user is not activated.

HTH

Andrew


2009/4/9 Tadatoshi T. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.