Getting user session object in cucumber

Hi, I am learning cucumber. I have integrated the Devise with my rails 3 application. My problem is I have to write a test which will create a project. For that I have to make sure that user should be logged in. So I have written the user login feature first which is working fine. After that I have written the creation of project scenario. Whenever I am running that scenario we are getting an error that user is not logged in and it gets redirected to the login page. My code is like this:-

Feature:- "Feature: Manage List Of Projects In order to keep track of Projects User should be able to Create a new project

Scenario: User logged in or not Given user on login page When user login with valid credentials Then user should be on project list page

Scenario: Create New Project When user create a project with name "Test" Then user should see "Test" on project list page"

My Steps are as follows:-

Given /^user on (.+)$/ do |page_name|   visit path_to(page_name) end

When /^user login with valid credentials$/ do   fill_in('Email', :with=>"john_rennie@gmail.com")   fill_in('Password', :with=>"neova123")   click_button("Login") end

Then /^user should be on project (.+)$/ do |page_name|   current_path = URI.parse(current_url).path   if current_path.respond_to? :should     current_path.should == path_to(page_name)   else     assert_equal path_to(page_name), current_path   end end

When /^user create a project with name "([^"]*)"$/ do |project_name|   visit new_project_path   fill_in("project_name", :with=>project_name)   click_button("Add Property") end " I know that I am missing something but as I am learner I am not able to figure out. Can anyone tell me How can I solve this? Please it is very urgent.

Thanks, Mike

In your second scenario the user is not logged in. prepend the steps from scenario 1 into scenario 2. I would recommend a "As a logged in user" etc.