I've got a cucumber step: Given that I'm logged in
I don't understand how I should implement it as a step definition.
Could someone point me into right direction, tutorials, blogs etc.
Add a Step Definition file 1) Create a new Class file in the 'stepDefinition' package and name it as 'Test_Steps', by right click on the Package and select New > Class. Do not check the option for 'public static void main' and click on Finish button. Take a look at the message in the console window.
If Cucumber is telling you that your steps are undefined, when you have defined step definitions, this means that Cucumber cannot find your step definitions. You'll need to make sure to specify the path to your step definitions (glue path) correctly.
Try using glue = {"stepDefinition.
here 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 = '[email protected]'
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 it this way, is that I run through the entire stack and set the environment up the way a normal user would...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With