Get Started with Calabash:

It will create a Cucumber skeleton in the current folder In this skeleton you find all the predefined steps that comes with calabash. Try to take a look my_first.feature and change it to fit your app. Also, there will be sample step_definitions created for you

Feature: Adding Cameras
As a user able to connect a camera
Scenario:
Given I am on the Welcome Screen
When I press Add button
And I press Connect to a camera
And I enter IP, Camera name, username and password
And I press Connect button
Then I should see rotate for fullscreen view

Sample step_definitions file:

# features/step_definitions/addcamera_steps.rb
require 'rspec/expectations'
require 'calabash-android/operations'
extend Calabash::Android::Operations
Given(/^I am on the Welcome Screen$/) do
wait_for(25) do
sleep(25)
end
end
When(/^I press Add button$/) do
touch("webView css:'#ext-gen1084'")
end
When(/^I press Connect to a camera$/) do
# To find the id of the button to touch, check the Running test
# from Console below
touch("webView css: '#ext-gen1160'")
end
When(/^I enter IP, Camera name, username and password$/) do
touch("webView css:'#ext-gen1197'")
set_text("webView css:'#ext-gen1197'", '10.220.x.x')
end

Running test with cucumber and calabash-android:

> bundle exec calabash-android run mytest.apk

Running test from console:

To test with an emulator:

# start the emulator on a command window:
> android
# Make sure Android SDK Tools, Platform Tools and Build Tools
# are installed
# Create an emulator and start the emulator
# Tools > Manage AVDs
# Create New and select the profile that you need.
# If you want verbose on add -v at the end of the foll. command
> calabash-android console mytest.apk

To test with an actual android device:

* Connect the device with usb
* In the AndroidManifest.xml file, add android:debuggable="true" to the
<application> element.
* Enable USB debugging on your device.
* On most devices running Android 3.2 or older, you can find the
option under Settings > Applications > Development.
* On Android 4.0 and newer, it's in Settings > Developer options.
* You might have to do “adb kill-server” and “adb start-server” to see
the device in “adb devices”

The contents of the file are a JSON-encoded hash in the from of:
RULE : MATCH_LIST

The MATCH_LIST can be:

rule:*
role:*
KEY:%(CONTEXT_KEY)s

RULE will be in the form of the following for specific checks.

COMPONENT:ACTION

When a MATCH_LIST for a rule:* is found, it acts as a link to the other rule
to perform checking.

When a MATCH_LIST for a role:* is found, the auth context of the request is
checked and made sure it contains the named role.

When a KEY:%(CONTEXT_KEY)s check is found, the KEY for the checked object
(an instnace model, a network address, a volume, etc) is compared to the
CONTEXT_KEY from the checked context. The admin_or_owner uses this type
of check for project_id matching between the context and the checked object.

Line #1:

RULE can be a custom name that is referenced by a MATCH_LIST.

“admin_or_owner”: [[“role:admin”], [“project_id:%(project_id)s”]]

“admin_or_owner” is just a RULE name
The rule defines that if the user has admin role OR he is the owner of the project
Note the box separating the role admin and the project id, that shows that it’s OR”

If you want to set a rule saying if the user is a member AND owner of the project“admin_and_owner”: [[“role:admin”, “project_id:%(project_id)s”]], “admin_and_owner” is the rule name
Note there is no box separation between role member and project id that shows that it’s AND”

5. When users are created through dashboard, they default to a tenant. So, always a user would be a member of a project.

6. mysql > keystone> users table:

a. If users table has the tenant_id set to “NULL” and if the user has roles set in the keystone, then still would be able to do whatever that role is allowed to do
b. If users table has the tenant_id set to a tenant for eg., 1 or 2…, and if no role or object is set, still the user would be able to do the actions which are set as []
c. There is no concept of project manager by default as we had in bexar. Owner doesn’t mean that the user is the project manager of the project, it just means that the user is a member of the project.