cs-bdd 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/cs/bdd/locales/en.yml +1 -0
- data/lib/cs/bdd/locales/pt.yml +1 -0
- data/lib/cs/bdd/version.rb +1 -1
- data/lib/skeleton/.gitignore +4 -0
- data/lib/skeleton/Gemfile +3 -3
- data/lib/skeleton/config/cucumber.yml +2 -2
- data/lib/skeleton/config/scripts/android/run_tests_all_devices.sh +1 -1
- data/lib/skeleton/config/scripts/ios/build_app.rb +3 -3
- data/lib/skeleton/config/scripts/ios/run_tests_all_devices.sh +1 -1
- data/lib/skeleton/features/ios/support/01_launch.rb +5 -12
- data/lib/skeleton/features/support/exceptions.rb +11 -0
- data/lib/skeleton/screenshots/android/.gitkeep +0 -0
- data/lib/skeleton/screenshots/ios/.gitkeep +0 -0
- data/lib/templates/android_screen_base.tt +45 -0
- data/lib/templates/base_steps.tt +4 -1
- data/lib/templates/ios_screen_base.tt +61 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b6b20897fce7c934cbacf55b1b33bc5742ab46e
|
4
|
+
data.tar.gz: 4762ff8d2b22f2dd53aaa4751bc544d7485d18bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eee698a839ea1aa8740027d7a00d0314d9f09013c3556609322e5194d3ffaaa8c925bda88f2bdb92aa7a6cda8e035d9f3956f91aade882dc1dcc5ac91cc058f5
|
7
|
+
data.tar.gz: 5bd7d5e102efdb0326dc15431b10fa9e852f55620d60f7955f56a2dacd2cd7997f870c036e8fb162446d82e268f98d249c855e7d60d3dc425fb63a9ecff9f144
|
data/README.md
CHANGED
@@ -54,17 +54,17 @@ This command will create a folder named ProjectName in the current directory and
|
|
54
54
|
cs-bdd new ProjectName --lang=pt
|
55
55
|
```
|
56
56
|
|
57
|
-
> The default language is English ('en'). The elements of Gherkin such as Given, When,
|
57
|
+
> The default language is English ('en'). The elements of Gherkin such as Given, When, Then, And, Scenario will be translated to all Gherkin supported languages, but this gem has just a few translation files (see that in folder: `lib/cs/bdd/locales`).
|
58
58
|
|
59
59
|
> **CS-BDD doesn't support your mother language?** No problem. Fork it, create your yml translation file, uses the en.yml file as a template. Translate it and make a pull request. There are only 15 lines to be translated, this will take no time.
|
60
60
|
|
61
|
-
> **
|
61
|
+
> **Want to know how to name your translation yml file?** See the Gherkin supported languages [here](https://github.com/cucumber/gherkin/blob/master/lib/gherkin/i18n.json) for reference.
|
62
62
|
|
63
63
|
Once the project is created, open its folder (`cd ProjectName`) and run `bundle install`
|
64
64
|
|
65
65
|
> This project supports both Android and iOS, so if you are on a PC you will not need the gems that are only for Macs, so you can run the command `bundle install --without mac_os`
|
66
66
|
|
67
|
-
> Remember to fix
|
67
|
+
> Remember to fix the calabash-cucumber version on the Gemfile. When updating the calabash-cucumber gem version you need to update the Calabash framework that was embedded on your iOS code. So, my suggestion is to update it manually. [In this page](https://github.com/calabash/calabash-ios/wiki/B1-Updating-your-Calabash-iOS-version) you can find more information on how to update the Calabash framework.
|
68
68
|
|
69
69
|
|
70
70
|
There are nine generators that are responsible to create the templates for Features, Step definitions and Screens.
|
data/lib/cs/bdd/locales/en.yml
CHANGED
data/lib/cs/bdd/locales/pt.yml
CHANGED
@@ -19,6 +19,7 @@ pt:
|
|
19
19
|
take_print: "faço um print"
|
20
20
|
been_in_page: "que eu (?:estou|estava) na (?:página|tela)(?: de|) '(.*?)'"
|
21
21
|
move_to_page: "eu (?:devo|deveria) estar na (?:página|tela)(?: de|) '(.*?)'"
|
22
|
+
restart_app: "(Eu |)reiniciar o aplicativo"
|
22
23
|
directions:
|
23
24
|
up: 'cima'
|
24
25
|
down: 'baixo'
|
data/lib/cs/bdd/version.rb
CHANGED
data/lib/skeleton/.gitignore
CHANGED
data/lib/skeleton/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Gemfile to help setting up the initial development environment
|
2
2
|
source 'https://rubygems.org'
|
3
3
|
|
4
|
-
gem 'calabash-common'
|
5
|
-
gem 'calabash-android', '~> 0.
|
6
|
-
gem 'calabash-cucumber', '~> 0.
|
4
|
+
gem 'calabash-common'
|
5
|
+
gem 'calabash-android', '~> 0.7.0'
|
6
|
+
gem 'calabash-cucumber', '~> 0.19.0'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# config/cucumber.yml
|
2
2
|
##YAML Template
|
3
3
|
---
|
4
|
-
android: PLATFORM=android -r features/support -r features/android -r features/step_definitions --exclude features/ios
|
4
|
+
android: PLATFORM=android SCREENSHOT_PATH=screenshots/android/ -r features/support -r features/android -r features/step_definitions --exclude features/ios
|
5
5
|
|
6
6
|
|
7
|
-
ios: PLATFORM=ios -r features/support -r features/ios -r features/step_definitions --exclude features/android
|
7
|
+
ios: PLATFORM=ios SCREENSHOT_PATH=screenshots/ios/ -r features/support -r features/ios -r features/step_definitions --exclude features/android
|
@@ -28,7 +28,7 @@ do
|
|
28
28
|
mkdir "$reports_path"/"$device"
|
29
29
|
|
30
30
|
{
|
31
|
-
ADB_DEVICE_ARG=$device
|
31
|
+
ADB_DEVICE_ARG=$device calabash-android run $1 -p android SCREENSHOT_PATH="$reports_path"/"$device"/ -f 'Calabash::Formatters::Html' -o "$reports_path"/"$device"/reports.html -f junit -o "$reports_path"/"$device"
|
32
32
|
# Calabash has a problem with images relative path, the command above will replace all the images path on the
|
33
33
|
# html report file to be a relative path
|
34
34
|
sed -i.bak 's|'"$reports_path"/"$device"/'||g' "$reports_path"/"$device"/reports.html
|
@@ -26,16 +26,16 @@ if ARGV.length != 1
|
|
26
26
|
exit 1
|
27
27
|
end
|
28
28
|
|
29
|
-
puts "Starting at #{Time.now.strftime('%H:%M:%S')}"
|
30
|
-
|
31
29
|
if config[ARGV[0]].nil?
|
32
30
|
puts 'Error: Wrong configuration environment!'
|
33
|
-
puts "Available Environments: #{config.keys}"
|
31
|
+
puts "Available Environments: #{config.keys.join(', ')}"
|
34
32
|
exit 1
|
35
33
|
else
|
36
34
|
config = config[ARGV[0]]
|
37
35
|
end
|
38
36
|
|
37
|
+
puts "Starting at #{Time.now.strftime('%H:%M:%S')}"
|
38
|
+
|
39
39
|
# Creating a folder name from the destination configuration parameter
|
40
40
|
folder_name = config['destination'].gsub('platform=', '').gsub('name=', '')
|
41
41
|
.tr(' ', '_').tr(',', '_')
|
@@ -45,7 +45,7 @@ do
|
|
45
45
|
fi
|
46
46
|
|
47
47
|
# Executing calabash for the device or simulator
|
48
|
-
APP_BUNDLE_PATH="$APP_PATH" DEVICE_TARGET="$UUID" DEVICE_ENDPOINT="$IP" SCREENSHOT_PATH="$reports_path"/"$NAME"/
|
48
|
+
APP_BUNDLE_PATH="$APP_PATH" DEVICE_TARGET="$UUID" DEVICE_ENDPOINT="$IP" cucumber -p ios SCREENSHOT_PATH="$reports_path"/"$NAME"/ -f 'Calabash::Formatters::Html' -o "$reports_path"/"$NAME/reports.html" -f junit -o "$reports_path"/"$NAME"
|
49
49
|
|
50
50
|
# Calabash has a problem with images relative path, the command above will replace all the images path on the
|
51
51
|
# html report file to be a relative path
|
@@ -54,21 +54,14 @@ Before do |scenario|
|
|
54
54
|
|
55
55
|
FeatureMemory.feature = feature
|
56
56
|
FeatureMemory.invocation = 1
|
57
|
-
unless launcher.calabash_no_launch?
|
58
|
-
launcher.relaunch(options)
|
59
|
-
launcher.calabash_notify(self)
|
60
|
-
end
|
61
|
-
end
|
62
57
|
|
63
|
-
|
64
|
-
|
58
|
+
launcher.relaunch(options)
|
59
|
+
# Avoid resetting when is not necessary
|
60
|
+
options[:reset] = false
|
65
61
|
end
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
if launcher.simulator_target?
|
70
|
-
launcher.simulator_launcher.stop unless launcher.calabash_no_stop?
|
71
|
-
end
|
63
|
+
After do
|
64
|
+
calabash_exit if launcher.quit_app_after_scenario?
|
72
65
|
end
|
73
66
|
|
74
67
|
def device?
|
File without changes
|
File without changes
|
@@ -11,6 +11,51 @@ class AndroidScreenBase < Calabash::ABase
|
|
11
11
|
alias_method :trait, :element
|
12
12
|
end
|
13
13
|
|
14
|
+
def restart_app
|
15
|
+
shutdown_test_server
|
16
|
+
start_test_server_in_background
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(method, *args)
|
20
|
+
if method.to_s.start_with?('touch_')
|
21
|
+
# If method name starts with touch_, executes the touch
|
22
|
+
# screen element method using the element name which is the
|
23
|
+
# method name without the first 'touch_' chars
|
24
|
+
touch_screen_element public_send(method.to_s.sub('touch_', ''))
|
25
|
+
elsif method.to_s.start_with?('enter_')
|
26
|
+
# If method starts with enter_, execute the enter method using
|
27
|
+
# the field name, which is the method name without the initial
|
28
|
+
# 'enter_' chars and appended '_field' chars
|
29
|
+
enter args[0], public_send("#{method.to_s.sub('enter_', '')}_field")
|
30
|
+
elsif method.to_s.end_with?('_visible?')
|
31
|
+
# If method ends with _visible?, executes the visible? method
|
32
|
+
# The field name is the method name without de ending
|
33
|
+
# '_visible? chars
|
34
|
+
visible? public_send(method.to_s.sub('_visible?', ''))
|
35
|
+
elsif method.to_s.end_with?('_visible!')
|
36
|
+
# Do the same as the method above, but throws an exception
|
37
|
+
# if the field is not visible
|
38
|
+
field_name = method.to_s.sub('_visible!', '')
|
39
|
+
.sub('_field', '')
|
40
|
+
.sub('_', ' ')
|
41
|
+
.capitalize
|
42
|
+
raise ElementNotFoundError, "ID: #{field_name}" unless
|
43
|
+
visible? public_send(method.to_s.sub('_visible!', ''))
|
44
|
+
else
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def visible?(id, query = nil)
|
50
|
+
query = "* id:'#{id}'" if query.nil?
|
51
|
+
begin
|
52
|
+
wait_for(timeout: 3) { element_exists query }
|
53
|
+
rescue
|
54
|
+
return false
|
55
|
+
end
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
14
59
|
element(:loading_screen) { 'insert_loading_view_id' }
|
15
60
|
|
16
61
|
# The progress bar of the application is a custom view
|
data/lib/templates/base_steps.tt
CHANGED
@@ -21,6 +21,10 @@ end
|
|
21
21
|
@page.drag_to direction.to_sym
|
22
22
|
end
|
23
23
|
|
24
|
+
<%= I18n.translate( :when ).capitalize %>(/^<%= I18n.translate( "steps.restart_app" ) %>$/) do
|
25
|
+
@page.restart_app
|
26
|
+
end
|
27
|
+
|
24
28
|
######### <%= I18n.translate( :then ).upcase %> #########
|
25
29
|
|
26
30
|
<%= I18n.translate( :then ).capitalize %>(/^<%= I18n.translate "steps.wait_progress_bar" %>$/) do
|
@@ -41,5 +45,4 @@ end
|
|
41
45
|
<%= I18n.translate( :then ).capitalize %>(/^<%= I18n.translate "steps.take_print" %>$/) do
|
42
46
|
screenshot_embed
|
43
47
|
end
|
44
|
-
|
45
48
|
<% end %>
|
@@ -11,6 +11,55 @@ class IOSScreenBase < Calabash::IBase
|
|
11
11
|
alias_method :trait, :element
|
12
12
|
end
|
13
13
|
|
14
|
+
def restart_app
|
15
|
+
# Relaunch options
|
16
|
+
options = { timeout: 3000 }
|
17
|
+
|
18
|
+
launcher.relaunch(options)
|
19
|
+
launcher.calabash_notify(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(method, *args)
|
23
|
+
if method.to_s.start_with?('touch_')
|
24
|
+
# If method name starts with touch_, executes the touch
|
25
|
+
# screen element method using the element name which is the
|
26
|
+
# method name without the first 'touch_' chars
|
27
|
+
touch_screen_element public_send(method.to_s.sub('touch_', ''))
|
28
|
+
elsif method.to_s.start_with?('enter_')
|
29
|
+
# If method starts with enter_, execute the enter method using
|
30
|
+
# the field name, which is the method name without the initial
|
31
|
+
# 'enter_' chars and appended '_field' chars
|
32
|
+
enter args[0], public_send("#{method.to_s.sub('enter_', '')}_field")
|
33
|
+
elsif method.to_s.end_with?('_visible?')
|
34
|
+
# If method ends with _visible?, executes the visible? method
|
35
|
+
# The field name is the method name without de ending
|
36
|
+
# '_visible? chars
|
37
|
+
visible? public_send(method.to_s.sub('_visible?', ''))
|
38
|
+
elsif method.to_s.end_with?('_visible!')
|
39
|
+
# Do the same as the method above, but throws an exception
|
40
|
+
# if the field is not visible
|
41
|
+
field_name = method.to_s.sub('_visible!', '')
|
42
|
+
.sub('_field', '')
|
43
|
+
.sub('_', ' ')
|
44
|
+
.capitalize
|
45
|
+
raise ElementNotFoundError, "ID: #{field_name}" unless
|
46
|
+
visible? public_send(method.to_s.sub('_visible!', ''))
|
47
|
+
else
|
48
|
+
super
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def visible?(id, query = nil)
|
53
|
+
query = "* id:'#{id}'" if query.nil?
|
54
|
+
begin
|
55
|
+
wait_for(timeout: 3) { element_exists query }
|
56
|
+
rescue
|
57
|
+
return false
|
58
|
+
end
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
|
14
63
|
element(:loading_screen) { 'LOADING' }
|
15
64
|
|
16
65
|
# The progress bar of the application is a custom view
|
@@ -26,6 +75,18 @@ class IOSScreenBase < Calabash::IBase
|
|
26
75
|
|
27
76
|
def drag_to(direction, element = nil)
|
28
77
|
element = 'tableView' if element.nil?
|
78
|
+
|
79
|
+
case(direction)
|
80
|
+
when :<%= (I18n.translate "directions.down").to_sym %>
|
81
|
+
direction = :down
|
82
|
+
when :<%= (I18n.translate "directions.up").to_sym %>
|
83
|
+
direction = :up
|
84
|
+
when :<%= (I18n.translate "directions.left").to_sym %>
|
85
|
+
positions = :left
|
86
|
+
when :<%= (I18n.translate "directions.right").to_sym %>
|
87
|
+
positions = :right
|
88
|
+
end
|
89
|
+
|
29
90
|
scroll(element, direction)
|
30
91
|
sleep(1)
|
31
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cs-bdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Tanner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -128,6 +128,9 @@ files:
|
|
128
128
|
- lib/skeleton/features/ios/support/01_launch.rb
|
129
129
|
- lib/skeleton/features/ios/support/02_pre_stop_hooks.rb
|
130
130
|
- lib/skeleton/features/support/env.rb
|
131
|
+
- lib/skeleton/features/support/exceptions.rb
|
132
|
+
- lib/skeleton/screenshots/android/.gitkeep
|
133
|
+
- lib/skeleton/screenshots/ios/.gitkeep
|
131
134
|
- lib/templates/android_screen_base.tt
|
132
135
|
- lib/templates/base_steps.tt
|
133
136
|
- lib/templates/feature.tt
|