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.
32a7dd6ad1b55d5f11c76fe38bd6af69?d=identicon&s=25 Tadatoshi Takahashi (tadatoshi)
on 2009-04-10 00:37
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 => 'quire@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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-04-10 09:17
(Received via mailing list)
On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi
<lists@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?
32a7dd6ad1b55d5f11c76fe38bd6af69?d=identicon&s=25 Tadatoshi Takahashi (tadatoshi)
on 2009-04-12 01:04
David Chelimsky wrote:
> On Thu, Apr 9, 2009 at 7:37 PM, Tadatoshi Takahashi
> <lists@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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-04-12 23:41
(Received via mailing list)
On Sat, Apr 11, 2009 at 8:04 PM, Tadatoshi Takahashi
<lists@ruby-forum.com> 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?
C694a032be7518a0d704318895f8fe1d?d=identicon&s=25 Ben Mabey (mabes)
on 2009-04-13 00:23
(Received via mailing list)
David Chelimsky 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 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
This topic is locked and can not be replied to.