Cucumber and the steps

Hello everybody !

Now you can write your steps in cucumber and implement in ruby and calabash… I am using Sublime, but you can use whatever IDE that supports ruby to write the features and the rb.

Steps – Example:

Feature: Search – True And False Results      # This is the name of the feature

Scenario Outline: Search                                 # This is the name of scenario

And look for: something                              # This is one step

And save the file like Search.feature -> in the folder features (Remember the folders of calabash have to stay inside of project’s folder), in this case I wrote a case of search of an app.

If you run now, without write the ruby file, the console will show the step you have to use in the ruby file, the calabash changes somethings of your feature to run in ruby.

And the code in ruby is:

#encoding: utf-8
require ‘calabash-cucumber’
require ‘calabash-cucumber/keyboard_helpers’

Given look for: something do                     # This is the step of the feature
tapicon openmenu‘                                   # This is the command to tap in something in your app, you have to know first a id or label (I will explain how you can take this informations in a next post)
sleep 3                                                       # This command is to stop the execution for 3 seconds
touch(Label text:buscar‘”)                       # This command is to touch, like the tap, but you can use this command with querys too, different of tap that just use label or id
keyboard_enter_text something             # This command is to write something in the field wich you touched in the last command
end                                                            # This finalize this step, you have to write this every final of step

Save the file like Search.rb inside the folder step_definitions. Don’t forget the words in bold, every file of ruby and calabash have to have this words on head. This means that you have to import the lib of cucumber in this file and the file will accept the words of your feature file.

Run cucumber in the terminal, you have to inside of the project’s folder.

If the simulator don’t open, you have to write the local that your app is inside the param APP_BUNDLE_PATH. So will stay like this:

APP_BUNDLE_PATH=”Local of your app” cucumber 

If you wants open the console, the command is:

calabash-ios console

If the console don’t open for the same reason in the step here, you have to write the param of APP_BUNDLE_PATH again.

APP_BUNDLE_PATH=”Local of your app” calabash-ios console

If you wants install another lib in ruby you have to install in your terminal. I had to install a lib to generate a CPF. The command is:

gem install cpf_cnpj

After this, I just had import in the file of ruby like we did with cucumber, and stay like this:

require ‘cpf_cnpj

For now it is this 🙂  I will write many things about this in next time !

Bye Bye !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.