[rspec-users] Persisting Logins and Sessions across scenarios

James Byrne lists at ruby-forum.com
Mon Jan 12 11:45:07 EST 2009

I have an authentication filter on my application controller. I have the
following feature statements:

  Scenario: I should be logged in to do any of this
    Given we have a user named "myuser"
      And the user named "myuser" logs in
    When they visit the "entities" page
    Then they should see the "entities" page

  Scenario: Entity should have essential identification information

    Given I do not have any entities
      And I am on the add a new entity page
    When I enter "My Business Relation" in the "Common Name" field
      And I enter "My B.R. Legal Name" in the "Legal Name" field
      And I choose "Corporation" as the "Legal Form"
      And I press "Create"
    Then I should save the entity information successfully

In scenario 1, the user is logged in successfully and the response body
after the 'see the "entities" page' is indeed the entities/index page.

When /should see the "(entities)" page/ do |resource|
  response.body.should =~ /All Entities/m

When /on the add a new entity page/ do
  visits new_entity_path
  response.body.should =~ /Add a New Entity/m

However, in Scenario 2, I am assuming that a.) the same user (myuser)
and their associated login session is employed.  Since the response body
from this is the login page then evidently this assumption is wrong and
something else is going on.  Can some inform me as to how test logins
are managed/maintained/reused within cucumber/webrat?
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list