File tree Expand file tree Collapse file tree 4 files changed +50
-3
lines changed
calabash-android-features-skeleton/support Expand file tree Collapse file tree 4 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11require 'calabash-android/management/app_installation'
22
3- AfterConfiguration do |config |
3+ AfterConfiguration do |_config |
44 FeatureMemory . feature = nil
55end
66
77Before do |scenario |
8- scenario = scenario . scenario_outline if scenario . respond_to? ( :scenario_outline )
8+ scenario = scenario . scenario_outline if scenario . respond_to? (
9+ :scenario_outline
10+ )
911
1012 feature = scenario . feature
1113 if FeatureMemory . feature != feature || ENV [ 'RESET_BETWEEN_SCENARIOS' ] == '1'
Original file line number Diff line number Diff line change @@ -47,6 +47,45 @@ def tags_for_user_id(user_id)
4747 user_scenario . tags . reject { |tag | tag == user_tag }
4848 end
4949
50+ def right_syntax?
51+ all_scenarios_have_a_user_tag? &&
52+ only_one_user_tag_for_each_scenario? &&
53+ !duplicate_tags_for_a_user?
54+ end
55+
56+ def duplicate_tags_for_a_user?
57+ taken_user_tags = { }
58+ scenarios . each do |scenario |
59+ user_tag = scenario . tags . select do |tag |
60+ tag . start_with? ( '@user' )
61+ end . first
62+ return true unless taken_user_tags [ user_tag ] . nil?
63+
64+ taken_user_tags [ user_tag ] = user_tag
65+ end
66+ false
67+ end
68+
69+ def only_one_user_tag_for_each_scenario?
70+ scenarios . each do |scenario |
71+ user_tags = scenario . tags . select do |tag |
72+ tag . start_with? ( '@user' )
73+ end
74+ return false if user_tags . count != 1
75+ end
76+ true
77+ end
78+
79+ def all_scenarios_have_a_user_tag?
80+ scenarios . each do |scenario |
81+ user_tag = scenario . tags . select do |tag |
82+ tag . start_with? ( '@user' )
83+ end . first
84+ return false if user_tag . nil?
85+ end
86+ true
87+ end
88+
5089 private
5190
5291 def read_content
Original file line number Diff line number Diff line change 1+ require 'kraken-mobile/helpers/feature_analyzer'
12require 'kraken-mobile/mobile/mobile_process'
23require 'kraken-mobile/models/feature_file'
34require 'kraken-mobile/models/web_device'
@@ -34,6 +35,11 @@ def before_execution
3435 end
3536
3637 def run
38+ unless @feature_file . right_syntax?
39+ raise "ERROR: Verify feature file #{ @file_path } has one unique @user tag" \
40+ ' for each scenario'
41+ end
42+
3743 before_execution
3844 execute
3945 after_execution
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def start
2828 #-------------------------------
2929 # Helpers
3030 #-------------------------------
31- def apk_path_for_process_id ( process_id )
31+ def apk_path_for_process_id ( _process_id )
3232 @apk_path
3333 end
3434
You can’t perform that action at this time.
0 commit comments