[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://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 => ‘[email protected]’,
: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

On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi T.
[email protected] 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?

David C. wrote:

On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi T.
[email protected] 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

David C. wrote:

I am sorry for the late reply.
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 P., using cucumber with
restful_auth: GitHub - diabolo/fbrp: Feature Based Rails Project

You might learn something by looking at that codebase.

HTH,
Ben

  1. http://wiki.github.com/aslakhellesoy/cucumber/related-tools

On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi T.
[email protected] wrote:

Cucumber cannot locate a field (its value is filled in text field).
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?