On Mon, Jan 12, 2009 at 6:21 PM, David Chelimsky <dchelim...@gmail.com>wrote:
> On Mon, Jan 12, 2009 at 10:45 AM, James Byrne <li...@ruby-forum.com> > wrote: > > 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 > > end > > > > When /on the add a new entity page/ do > > visits new_entity_path > > response.body.should =~ /Add a New Entity/m > > end > > > > > > 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? > > Each scenario operates in a new session. > And coupling scenarios (or any kind of automated test - regardless of framework) is a very bad idea. Aslak > > I usually have a step that aggregates the login process: > > Given /^I am logged in as "(.*)"/ do |role| > #create a user whose name and role are based on the role > #log in that user > end > > This lets me say: > > Given I am logged in as "admin" > When I visit the super-secret page > Then I see it and learn about all its mystery > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users