Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Integration testing with Cucumber and AuthLogic x-post to Cucumber
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
byrnejb  
View profile  
 More options Dec 16 2010, 11:27 am
From: byrnejb <byrn...@harte-lyne.ca>
Date: Thu, 16 Dec 2010 08:27:09 -0800 (PST)
Local: Thurs, Dec 16 2010 11:27 am
Subject: Integration testing with Cucumber and AuthLogic x-post to Cucumber
I am trying to write a short-form login/logout step that works with
Authlogic (2.1.6) and I cannot seem to discover how to get this to
work.  Has anyone here managed to do this successfully?

I have tried this:

Before do
  activate_authlogic
end

When /user named "(.*)" logs in/ do |login|
  user = User.find_by_username( login.downcase )
  @local_user_session = UserSession.create!( user )
  puts( @local_user_session )
end

gives this:
#<UserSession: {:unauthorized_record=>"<protected>"}>

But this user session object does not seem to match what I get from
user_session_controller#create
#<UserSession:
{:password=>"<protected>", :username=>#<ActiveSupport::Multibyte::Chars:
0x2ac27e7afec0 @wrapped_string="myuser">}>

Destroying the UserSession gives the same result as the create
#<UserSession: {:unauthorized_record=>"<protected>"}>

I then changed to the alternate syntax and used the create! method.
This indicates the root of the problem:

  user = User.find_by_username!( name.hll_normalise )
  puts( user.username )
  @current_user_session = UserSession.create!(
    :login => user.username,
    :password => user.username + "-password",
    :remember_me => true )

gives:

tester
      Your session is invalid and has the following errors: Username
cannot be blank (Authlogic::Session::Existence::SessionInvalidError)
      ./features/app/models/users/step_definitions/
user_authentication_steps.rb:175:in `/user named "(.*)" is
authenticated/'
      features/app/models/users/user_authentication.feature:59:in `And
the user named "tester" is authenticated'

Is AuthLogic still actively supported?  I do not see any activity on
the GitHub repository since the beginning of September and the issues
list seems to be getting little attention as well.  If it has been
abandoned then which fork are people moving to?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
byrnejb  
View profile  
 More options Dec 16 2010, 1:11 pm
From: byrnejb <byrn...@harte-lyne.ca>
Date: Thu, 16 Dec 2010 10:11:36 -0800 (PST)
Local: Thurs, Dec 16 2010 1:11 pm
Subject: Re: Integration testing with Cucumber and AuthLogic x-post to Cucumber
On Dec 16, 11:27 am, byrnejb <byrn...@harte-lyne.ca> wrote:

> I am trying to write a short-form login/logout step that works with
> Authlogic (2.1.6) and I cannot seem to discover how to get this to
> work.  Has anyone here managed to do this successfully?

I think that I have figured out the secret decoder ring.

For Cucumber testing one must place somewhere in a file in the
features/support directory:

require 'authlogic/test_case'

Then one must first invoke the activate_authlogic_method or visit a
controller.  The simplest thing to do is to place the activate call
inside a Before block in a Cucumber step definition file:

Before do
  activate_authlogic
end

Then the UserSession.find returns a session object if one exists and
nil otherwise.  If a session exists then the #record method can be
used to examine the user.  So UserSession.find.record => user.instance
if UserSession.find;  Otherwise it fails since nil has no such
method.  I evidently had tripped over some conflict with instance
variables in my initial implementation and that completely confused
me.

With this information then the following is possible:

Then /user named "(.*)" is authenticated/ do |login|
  user = User.find_by_login!( login )
  UserSession.create!( user )
end

Then /user is not authenticated/ do
  UserSession.find.destroy
end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »