itms_automation 2.5 → 2.6.2
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/bin/generate.rb +3 -37
- data/bin/helper.rb +23 -10
- data/bin/itms_automation +18 -23
- data/doc/installation.md +16 -0
- data/doc/itms-automation-API.md +103 -0
- data/doc/itms-automation-help.md +18 -0
- data/example/android/android_app/android_app_calculator.zip +0 -0
- data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
- data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
- data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
- data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
- data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
- data/example/android/android_web/android_web_gmail_login.zip +0 -0
- data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
- data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
- data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
- data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
- data/example/desktop web/desktop_web_gmail_login.zip +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
- data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
- data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +106 -0
- data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +38 -0
- data/{project → features-skeleton}/Gemfile +0 -0
- data/features-skeleton/Gemfile.lock +63 -0
- data/features-skeleton/README.md +132 -0
- data/{project → features-skeleton}/cucumber.yml +0 -0
- data/features-skeleton/my_first.feature +10 -0
- data/features-skeleton/screenshots/test.png +0 -0
- data/features-skeleton/step_definitions/custom_steps.rb +5 -0
- data/features-skeleton/step_definitions/repositories/project_object.yml +1 -0
- data/features-skeleton/support/env.rb +105 -0
- data/features-skeleton/support/hooks.rb +38 -0
- data/lib/itms_automation.rb +1 -3
- data/lib/itms_automation/assertion_steps.rb +68 -0
- data/lib/itms_automation/click_elements_steps.rb +24 -0
- data/lib/itms_automation/configuration_steps.rb +7 -0
- data/lib/itms_automation/input_steps.rb +59 -0
- data/lib/itms_automation/javascript_handling_steps.rb +10 -0
- data/lib/itms_automation/methods/assertion_methods.rb +333 -0
- data/lib/itms_automation/methods/click_elements_methods.rb +22 -0
- data/lib/itms_automation/methods/configuration_methods.rb +35 -0
- data/lib/itms_automation/methods/error_handling_methods.rb +93 -0
- data/lib/itms_automation/methods/input_methods.rb +69 -0
- data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
- data/lib/itms_automation/methods/misc_methods.rb +63 -0
- data/lib/itms_automation/methods/navigate_methods.rb +123 -0
- data/lib/itms_automation/methods/progress_methods.rb +15 -0
- data/lib/itms_automation/methods/required_files.rb +9 -0
- data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
- data/lib/itms_automation/navigation_steps.rb +79 -0
- data/lib/itms_automation/progress_steps.rb +17 -0
- data/lib/itms_automation/screenshot_steps.rb +6 -0
- data/lib/itms_automation/version.rb +5 -3
- metadata +89 -75
- data/bin/console +0 -14
- data/bin/documentation_generator.rb +0 -119
- data/bin/setup +0 -8
- data/lib/itms_automation/all_steps.rb +0 -8
- data/lib/itms_automation/assertion_helper.rb +0 -29
- data/lib/itms_automation/auto_util.rb +0 -707
- data/lib/itms_automation/database_steps_helper.rb +0 -125
- data/lib/itms_automation/web_steps_helper.rb +0 -867
- data/project/Gemfile.lock +0 -92
- data/project/README.md +0 -34
- data/project/Rakefile +0 -24
- data/project/features/TestSuite/WebGUI.feature +0 -5
- data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
- data/project/features/step_definitions/repositories/project_object.yml +0 -26
- data/project/features/support/env.rb +0 -9
- data/project/features/support/hooks.rb +0 -122
@@ -0,0 +1,79 @@
|
|
1
|
+
# require 'cucumber'
|
2
|
+
# require_relative 'methods/navigate_methods'
|
3
|
+
|
4
|
+
# Then(/^I navigate to "([^\"]*)"$/)do |link|
|
5
|
+
# navigate_to(link)
|
6
|
+
# end
|
7
|
+
|
8
|
+
# Then(/^I navigate forward/) do
|
9
|
+
# navigate('forward')
|
10
|
+
# end
|
11
|
+
|
12
|
+
# Then(/^I navigate back/) do
|
13
|
+
# navigate('back')
|
14
|
+
# end
|
15
|
+
|
16
|
+
# Then(/^I close browser$/) do
|
17
|
+
# close_driver
|
18
|
+
# end
|
19
|
+
|
20
|
+
# # step to resize browser
|
21
|
+
# Then(/^I resize browser window size to width (\d+) and height (\d+)$/) do |width, heigth|
|
22
|
+
# resize_browser(width, heigth)
|
23
|
+
# end
|
24
|
+
|
25
|
+
# # step to maximize browser
|
26
|
+
# Then(/^I maximize browser window$/) do
|
27
|
+
# maximize_browser
|
28
|
+
# end
|
29
|
+
|
30
|
+
# # steps to refresh page
|
31
|
+
# Then(/^I refresh page$/) do
|
32
|
+
# refresh_page
|
33
|
+
# end
|
34
|
+
|
35
|
+
# Then(/^I switch to new window$/) do
|
36
|
+
# switch_to_new_window
|
37
|
+
# end
|
38
|
+
|
39
|
+
# Then(/^I switch to previous window$/) do
|
40
|
+
# switch_to_old_window
|
41
|
+
# end
|
42
|
+
|
43
|
+
# Then(/^I close new window$/) do
|
44
|
+
# close_new_window
|
45
|
+
# end
|
46
|
+
|
47
|
+
# # steps to scroll to element
|
48
|
+
# Then(/^I scroll to element "(.*?)"$/) do |type, element|
|
49
|
+
# scroll_to_element(type, element)
|
50
|
+
# end
|
51
|
+
|
52
|
+
# # steps to scroll web page to top or end
|
53
|
+
# Then(/^I scroll to (top|end) of page$/) do |to|
|
54
|
+
# scroll_page(to)
|
55
|
+
# end
|
56
|
+
|
57
|
+
# # step to hover over a element Note: Doesn't work on Windows firefox
|
58
|
+
# When(/^I hover over element having (.+) "(.*?)"$/) do |type, element|
|
59
|
+
# hover_over_element(type, element)
|
60
|
+
# end
|
61
|
+
|
62
|
+
# # steps to zoom in page
|
63
|
+
# Then(/^I zoom in page$/) do
|
64
|
+
# zoom_in_out('add')
|
65
|
+
# end
|
66
|
+
|
67
|
+
# # steps to zoom out page
|
68
|
+
# Then(/^I zoom out page$/) do
|
69
|
+
# zoom_in_out('subtract')
|
70
|
+
# end
|
71
|
+
|
72
|
+
# # steps to zoom out till element displays
|
73
|
+
# Then(/^I zoom out page till I see element "(.*?)"$/) do |type, element|
|
74
|
+
# zoom_in_out_till_element_display(type, 'subtract', element)
|
75
|
+
# end
|
76
|
+
|
77
|
+
# Then(/^I reset page view$/) do
|
78
|
+
# zoom_in_out('numpad0')
|
79
|
+
# end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# require 'cucumber'
|
2
|
+
# require_relative 'methods/progress_methods'
|
3
|
+
|
4
|
+
# # wait for specific period of time
|
5
|
+
# Then(/^I wait for (\d+) sec$/) do |time|
|
6
|
+
# wait(time)
|
7
|
+
# end
|
8
|
+
|
9
|
+
# # wait for specific element to display for specific period of time
|
10
|
+
# Then(/^I wait (\d+) seconds for element "(.*?)" to display$/) do |duration, element|
|
11
|
+
# wait_for_element_to_display(element, duration)
|
12
|
+
# end
|
13
|
+
|
14
|
+
# # wait for specific element to enable for specific period of time
|
15
|
+
# Then(/^I wait (\d+) seconds for element "(.*?)" to enable$/) do |duration, element|
|
16
|
+
# wait_for_element_to_enable(element, duration)
|
17
|
+
# end
|
metadata
CHANGED
@@ -1,103 +1,95 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itms_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- INFOdation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: cucumber
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.
|
19
|
+
version: 3.1.2
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 3.1.2
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.
|
29
|
+
version: 3.1.2
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 3.1.2
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: selenium-webdriver
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '3.
|
40
|
-
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '3.1'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: capybara
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
39
|
+
version: '3.14'
|
40
|
+
- - ">="
|
52
41
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
42
|
+
version: 3.14.1
|
54
43
|
type: :runtime
|
55
44
|
prerelease: false
|
56
45
|
version_requirements: !ruby/object:Gem::Requirement
|
57
46
|
requirements:
|
58
47
|
- - "~>"
|
59
48
|
- !ruby/object:Gem::Version
|
60
|
-
version: 3.
|
49
|
+
version: '3.14'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.14.1
|
61
53
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
54
|
+
name: appium_lib_core
|
63
55
|
requirement: !ruby/object:Gem::Requirement
|
64
56
|
requirements:
|
65
57
|
- - ">="
|
66
58
|
- !ruby/object:Gem::Version
|
67
|
-
version: 3.
|
59
|
+
version: 3.10.1
|
68
60
|
- - "~>"
|
69
61
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
62
|
+
version: 3.10.1
|
71
63
|
type: :runtime
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
66
|
requirements:
|
75
67
|
- - ">="
|
76
68
|
- !ruby/object:Gem::Version
|
77
|
-
version: 3.
|
69
|
+
version: 3.10.1
|
78
70
|
- - "~>"
|
79
71
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
72
|
+
version: 3.10.1
|
81
73
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
74
|
+
name: httparty
|
83
75
|
requirement: !ruby/object:Gem::Requirement
|
84
76
|
requirements:
|
85
|
-
- - "~>"
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '2.7'
|
88
77
|
- - ">="
|
89
78
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
79
|
+
version: 0.13.7
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.13.7
|
91
83
|
type: :runtime
|
92
84
|
prerelease: false
|
93
85
|
version_requirements: !ruby/object:Gem::Requirement
|
94
86
|
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '2.7'
|
98
87
|
- - ">="
|
99
88
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
89
|
+
version: 0.13.7
|
90
|
+
- - "~>"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.13.7
|
101
93
|
- !ruby/object:Gem::Dependency
|
102
94
|
name: report_builder
|
103
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,53 +110,75 @@ dependencies:
|
|
118
110
|
- - "~>"
|
119
111
|
- !ruby/object:Gem::Version
|
120
112
|
version: '1.8'
|
121
|
-
- !ruby/object:Gem::Dependency
|
122
|
-
name: cucumber_priority
|
123
|
-
requirement: !ruby/object:Gem::Requirement
|
124
|
-
requirements:
|
125
|
-
- - "~>"
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: 0.3.2
|
128
|
-
type: :runtime
|
129
|
-
prerelease: false
|
130
|
-
version_requirements: !ruby/object:Gem::Requirement
|
131
|
-
requirements:
|
132
|
-
- - "~>"
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: 0.3.2
|
135
113
|
description: Behavior driven development (BDD) approach to write automation test script
|
136
|
-
to test
|
137
|
-
email:
|
138
|
-
- anhpq.info@gmail.com
|
114
|
+
to test Web and Android applications.
|
115
|
+
email: anh.pham@infodation.vn
|
139
116
|
executables:
|
140
117
|
- itms_automation
|
141
118
|
extensions: []
|
142
119
|
extra_rdoc_files: []
|
143
120
|
files:
|
144
|
-
- bin/console
|
145
|
-
- bin/documentation_generator.rb
|
146
121
|
- bin/generate.rb
|
147
122
|
- bin/helper.rb
|
148
123
|
- bin/itms_automation
|
149
|
-
-
|
124
|
+
- doc/installation.md
|
125
|
+
- doc/itms-automation-API.md
|
126
|
+
- doc/itms-automation-help.md
|
127
|
+
- example/android/android_app/android_app_calculator.zip
|
128
|
+
- example/android/android_app/android_app_calculator/AndroidCalculator.apk
|
129
|
+
- example/android/android_app/android_app_calculator/features/calculator.feature
|
130
|
+
- example/android/android_app/android_app_calculator/features/my_first.feature
|
131
|
+
- example/android/android_app/android_app_calculator/features/screenshots/test.png
|
132
|
+
- example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb
|
133
|
+
- example/android/android_app/android_app_calculator/features/support/env.rb
|
134
|
+
- example/android/android_app/android_app_calculator/features/support/hooks.rb
|
135
|
+
- example/android/android_web/android_web_gmail_login.zip
|
136
|
+
- example/android/android_web/android_web_gmail_login/features/gmail_login.feature
|
137
|
+
- example/android/android_web/android_web_gmail_login/features/my_first.feature
|
138
|
+
- example/android/android_web/android_web_gmail_login/features/screenshots/test.png
|
139
|
+
- example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb
|
140
|
+
- example/android/android_web/android_web_gmail_login/features/support/env.rb
|
141
|
+
- example/android/android_web/android_web_gmail_login/features/support/hooks.rb
|
142
|
+
- example/desktop web/desktop_web_gmail_login.zip
|
143
|
+
- example/desktop web/desktop_web_gmail_login/features/gmail_login.feature
|
144
|
+
- example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature
|
145
|
+
- example/desktop web/desktop_web_gmail_login/features/my_first.feature
|
146
|
+
- example/desktop web/desktop_web_gmail_login/features/screenshots/test.png
|
147
|
+
- example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb
|
148
|
+
- example/desktop web/desktop_web_gmail_login/features/support/env.rb
|
149
|
+
- example/desktop web/desktop_web_gmail_login/features/support/hooks.rb
|
150
|
+
- features-skeleton/Gemfile
|
151
|
+
- features-skeleton/Gemfile.lock
|
152
|
+
- features-skeleton/README.md
|
153
|
+
- features-skeleton/cucumber.yml
|
154
|
+
- features-skeleton/my_first.feature
|
155
|
+
- features-skeleton/screenshots/test.png
|
156
|
+
- features-skeleton/step_definitions/custom_steps.rb
|
157
|
+
- features-skeleton/step_definitions/repositories/project_object.yml
|
158
|
+
- features-skeleton/support/env.rb
|
159
|
+
- features-skeleton/support/hooks.rb
|
150
160
|
- lib/itms_automation.rb
|
151
|
-
- lib/itms_automation/
|
152
|
-
- lib/itms_automation/
|
153
|
-
- lib/itms_automation/
|
154
|
-
- lib/itms_automation/
|
161
|
+
- lib/itms_automation/assertion_steps.rb
|
162
|
+
- lib/itms_automation/click_elements_steps.rb
|
163
|
+
- lib/itms_automation/configuration_steps.rb
|
164
|
+
- lib/itms_automation/input_steps.rb
|
165
|
+
- lib/itms_automation/javascript_handling_steps.rb
|
166
|
+
- lib/itms_automation/methods/assertion_methods.rb
|
167
|
+
- lib/itms_automation/methods/click_elements_methods.rb
|
168
|
+
- lib/itms_automation/methods/configuration_methods.rb
|
169
|
+
- lib/itms_automation/methods/error_handling_methods.rb
|
170
|
+
- lib/itms_automation/methods/input_methods.rb
|
171
|
+
- lib/itms_automation/methods/javascript_handling_methods.rb
|
172
|
+
- lib/itms_automation/methods/misc_methods.rb
|
173
|
+
- lib/itms_automation/methods/navigate_methods.rb
|
174
|
+
- lib/itms_automation/methods/progress_methods.rb
|
175
|
+
- lib/itms_automation/methods/required_files.rb
|
176
|
+
- lib/itms_automation/methods/screenshot_methods.rb
|
177
|
+
- lib/itms_automation/navigation_steps.rb
|
178
|
+
- lib/itms_automation/progress_steps.rb
|
179
|
+
- lib/itms_automation/screenshot_steps.rb
|
155
180
|
- lib/itms_automation/version.rb
|
156
|
-
|
157
|
-
- project/Gemfile
|
158
|
-
- project/Gemfile.lock
|
159
|
-
- project/README.md
|
160
|
-
- project/Rakefile
|
161
|
-
- project/cucumber.yml
|
162
|
-
- project/features/TestSuite/WebGUI.feature
|
163
|
-
- project/features/step_definitions/lib_steps/steps_definition.rb
|
164
|
-
- project/features/step_definitions/repositories/project_object.yml
|
165
|
-
- project/features/support/env.rb
|
166
|
-
- project/features/support/hooks.rb
|
167
|
-
homepage: http://rubygems.org/gems/itms_automation
|
181
|
+
homepage: http://infodation.nl/
|
168
182
|
licenses:
|
169
183
|
- MIT
|
170
184
|
metadata: {}
|
@@ -176,7 +190,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
190
|
requirements:
|
177
191
|
- - ">="
|
178
192
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
193
|
+
version: 1.9.3
|
180
194
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
195
|
requirements:
|
182
196
|
- - ">="
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "itms_automation"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
@@ -1,119 +0,0 @@
|
|
1
|
-
module DocumentationGenerator
|
2
|
-
|
3
|
-
module CommentExtractor
|
4
|
-
def parse_and_format_comment(comment)
|
5
|
-
comment.gsub!(/.*coding:.*UTF-8.*/, '')
|
6
|
-
comment.strip!
|
7
|
-
comment_lines = comment.split("\n").take_while { |line| line =~ /^\s*#/ }
|
8
|
-
comment_lines && comment_lines.join("\n").gsub(/^\s*# ?/, '')
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class StepDefinition
|
13
|
-
|
14
|
-
extend CommentExtractor
|
15
|
-
|
16
|
-
def initialize(definition, comment = nil)
|
17
|
-
@definition = definition
|
18
|
-
@comment = comment
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.try_and_parse(code)
|
22
|
-
definition = code[/^\s*((When|Then|Given|AfterStep).*)do/, 1]
|
23
|
-
return unless definition
|
24
|
-
comment = parse_and_format_comment(code)
|
25
|
-
return if comment =~ /\bnodoc\b/
|
26
|
-
new(definition.strip, comment)
|
27
|
-
end
|
28
|
-
|
29
|
-
def format
|
30
|
-
<<-TEXT
|
31
|
-
* **#{format_definition}**
|
32
|
-
|
33
|
-
#{@comment.gsub(/^/, ' ')}
|
34
|
-
TEXT
|
35
|
-
end
|
36
|
-
|
37
|
-
def format_definition
|
38
|
-
if @definition =~ /AfterStep/
|
39
|
-
@definition[/@\w*/]
|
40
|
-
else
|
41
|
-
capture_groups = %w[([^\"]*) ([^"]*) (.*) (.*?) [^"]+ ([^\"]+) ([^']*) ([^/]*) (.+) (.*[^:])]
|
42
|
-
capture_groups.map! &Regexp.method(:escape)
|
43
|
-
|
44
|
-
@definition.
|
45
|
-
gsub('/^', '').
|
46
|
-
gsub('$/', '').
|
47
|
-
gsub(' ?', ' ').
|
48
|
-
gsub('(?:|I )', 'I ').
|
49
|
-
gsub('?:', '').
|
50
|
-
gsub(Regexp.new(capture_groups.join '|'), '...').
|
51
|
-
gsub(/\\\//, '/')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class StepDefinitionFile
|
57
|
-
|
58
|
-
FILE_COMMENT_END = 'FILE_COMMENT_END'
|
59
|
-
|
60
|
-
include CommentExtractor
|
61
|
-
|
62
|
-
def initialize(filename)
|
63
|
-
@filename = filename
|
64
|
-
@code = File.read(filename)
|
65
|
-
@steps = []
|
66
|
-
extract_comment
|
67
|
-
add_steps
|
68
|
-
end
|
69
|
-
|
70
|
-
def extract_comment
|
71
|
-
if @code.include?(FILE_COMMENT_END)
|
72
|
-
file_comment = @code.split(FILE_COMMENT_END).first
|
73
|
-
@comment = parse_and_format_comment(file_comment)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def add_steps
|
78
|
-
@code.split("\n\n").each do |block|
|
79
|
-
step = StepDefinition.try_and_parse(block)
|
80
|
-
if step
|
81
|
-
@steps << step
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def format
|
87
|
-
<<-TEXT
|
88
|
-
### #{format_filename}
|
89
|
-
|
90
|
-
#{@comment}
|
91
|
-
|
92
|
-
#{format_steps}
|
93
|
-
TEXT
|
94
|
-
end
|
95
|
-
|
96
|
-
def format_filename
|
97
|
-
@filename.split('/').last
|
98
|
-
end
|
99
|
-
|
100
|
-
def format_steps
|
101
|
-
@steps.collect { |step| step.format }.join("\n\n")
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
class StepDefinitionsDirectory
|
106
|
-
def initialize(directory)
|
107
|
-
@step_definition_files = []
|
108
|
-
Dir["#{directory}/*.rb"].to_a.sort.each do |filename|
|
109
|
-
next if filename =~ /all_steps/
|
110
|
-
@step_definition_files << StepDefinitionFile.new(filename)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def format
|
115
|
-
@step_definition_files.collect { |step_definition_file| step_definition_file.format }.join("\n\n")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|