Determining the cucumber pitch for "Given that I logged in"

I have a cucumber step: given that I logged in

I do not understand how I should implement it as a definition of a step.

Can someone point me in the right direction, tutorials, blogs, etc.

+6
ruby ruby-on-rails rspec cucumber
source share
2 answers

this is how i do it.

Given /^I have one\s+user "([^\"]*)" with email "([^\"]*)" and password "([^\"]*)"$/ do |username,email, password| @user = User.new(:email => email, :username=>username, :password => password, :password_confirmation => password) @user.save! end Given /^I am an authenticated user$/ do name = 'exmample' email = ' example@example.com ' password = 'secret!' Given %{I have one user "#{name}" with email "#{email}" and password "#{password}"} And %{I go to the user login page} And %{I fill in "user_username" with "#{name}"} And %{I fill in "user_password" with "#{password}"} And %{I press "Sign in"} end 

The reason I do this is because I run the entire stack and set up the environment in a way that a regular user ...

+9
source share

Hi, you can divide this step into three small steps.

 1. visit login page 2. fill_in login, username 3. press login button 
+4
source share

All Articles