Tadatoshi Takahashi
2009-Apr-09 22:37 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
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=newest#sort-top http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features The step I added is: Given /^I am logged in$/ do User.create!( :first_name => ''quire'', :last_name => ''smith'', :login => ''quire'', :email => ''quire at example.com'', :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 -- Posted via http://www.ruby-forum.com/.
Tadatoshi Takahashi
2009-Apr-09 22:46 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
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=newest#sort-top http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features The step I added is: Given /^I am logged in$/ do User.create!( :first_name => ''quire'', :last_name => ''smith'', :login => ''quire'', :email => ''quire at example.com'', :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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090409/476fb6fc/attachment.html>
David Chelimsky
2009-Apr-10 07:14 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi <lists at ruby-forum.com> wrote:> 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=newest#sort-top > http://stackoverflow.com/questions/382473/how-do-i-fake-openid-login-in-rspec-user-story-cucumber-when-using-openidauthen > http://blog.andrew.premdas.org/articles/2008/10/12/cucumber-webrat-and-debugging-features > > > The step I added is: > > Given /^I am logged in$/ do > ?User.create!( :first_name => ''quire'', > ? ? ? ? ? ? ? ?:last_name => ''smith'', > ? ? ? ? ? ? ? ?:login => ''quire'', > ? ? ? ? ? ? ? ?:email => ''quire at example.com'', > ? ? ? ? ? ? ? ?: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).Where are you putting login_required?> > Thank you in advance. > > Tadatoshi > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Tadatoshi Takahashi
2009-Apr-11 23:04 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
David Chelimsky wrote:> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi > <lists at ruby-forum.com> wrote: >> what to do. >> ?User.create!( :first_name => ''quire'', >> >> 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). > > Where are you putting login_required?Hi, David. I am sorry for the late reply. The login_required I put is actually before_filter in the controller, e.g. before_filter :login_required. Basically, if I disabled restful_authentication by commenting it out, all the steps in Cucumber passed. But when I enabled it (putting the before_filter above), Cucumber failed at one step. I don''t necessary have a time to dig into the codes inside Cucumber and RSpec. So if there is a code that works, I would like to just use it and continue with Behaviour-Driven Development. Thank you. Tadatoshi -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2009-Apr-12 21:36 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi Takahashi <lists at ruby-forum.com> wrote:> David Chelimsky wrote: >> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi >> <lists at ruby-forum.com> wrote: >>> what to do. >>> ?User.create!( :first_name => ''quire'', >>> >>> 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). >> >> Where are you putting login_required? > > Hi, David. > > I am sorry for the late reply. > > The login_required I put is actually before_filter in the controller, > e.g. > before_filter :login_required. > Basically, if I disabled restful_authentication by commenting it out, > all the steps in Cucumber passed. But when I enabled it (putting the > before_filter above), Cucumber failed at one step. > > I don''t necessary have a time to dig into the codes inside Cucumber and > RSpec. So if there is a code that works, I would like to just use it and > continue with Behaviour-Driven Development.I haven''t personally set up any apps with restful_authentication and Cucumber. Is there anybody else on this who has who can help Tadatoshi out?> > Thank you. > > Tadatoshi > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
Ben Mabey
2009-Apr-12 22:21 UTC
[rspec-users] [cucumber] Cucumber and restful_authentication
David Chelimsky wrote:> On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi Takahashi > <lists at ruby-forum.com> wrote: > >> David Chelimsky wrote: >> >>> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi >>> <lists at ruby-forum.com> wrote: >>> >>>> what to do. >>>> ?User.create!( :first_name => ''quire'', >>>> >>>> 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). >>>> >>> Where are you putting login_required? >>> >> Hi, David. >> >> I am sorry for the late reply. >> >> The login_required I put is actually before_filter in the controller, >> e.g. >> before_filter :login_required. >> Basically, if I disabled restful_authentication by commenting it out, >> all the steps in Cucumber passed. But when I enabled it (putting the >> before_filter above), Cucumber failed at one step. >> >> I don''t necessary have a time to dig into the codes inside Cucumber and >> RSpec. So if there is a code that works, I would like to just use it and >> continue with Behaviour-Driven Development. >> > > I haven''t personally set up any apps with restful_authentication and > Cucumber. Is there anybody else on this who has who can help Tadatoshi > out? > >I have not used Cucumber with restful_auth. However, on the ''Related Tools'' page[1] on the wiki there are several links to projects that deal with Cucumber and authentication. One of them is a sample app, by Andrew Premdas, using cucumber with restful_auth: http://github.com/diabolo/fbrp/tree/master You might learn something by looking at that codebase. HTH, Ben 1. http://wiki.github.com/aslakhellesoy/cucumber/related-tools