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.
On Mar 21, 8:15 am, Mike Disuza
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> 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_ren...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org")
> 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
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.