itms_automation 2.2 → 2.5.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/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/features-skeleton/my_first.feature +5 -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 +106 -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 +23 -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 +78 -94
- 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 -699
- data/lib/itms_automation/database_steps_helper.rb +0 -125
- data/lib/itms_automation/web_steps_helper.rb +0 -838
- data/project/Gemfile +0 -3
- data/project/README.md +0 -34
- data/project/Rakefile +0 -24
- data/project/config/chrome_headless_options.yaml +0 -1
- data/project/config/chrome_options.yaml +0 -6
- data/project/config/firefox_headless_options.yaml +0 -1
- data/project/config/firefox_options.yaml +0 -1
- data/project/config/ie_options.yaml +0 -1
- data/project/config/remote_options.yaml +0 -6
- data/project/config/safari_options.yaml +0 -1
- data/project/cucumber.yml +0 -4
- data/project/features/TestSuite/WebGUI.feature +0 -4
- data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -3
- data/project/features/step_definitions/repositories/project_object.yml +0 -2
- data/project/features/support/env.rb +0 -10
- data/project/features/support/hooks.rb +0 -128
@@ -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,176 +1,160 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itms_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.5.7
|
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-20 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:
|
19
|
+
version: 3.1.2
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.
|
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:
|
29
|
+
version: 3.1.2
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: cucumber
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '3.1'
|
40
|
-
type: :runtime
|
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
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 3.29.0
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 3.29.0
|
32
|
+
version: 3.1.2
|
61
33
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
34
|
+
name: selenium-webdriver
|
63
35
|
requirement: !ruby/object:Gem::Requirement
|
64
36
|
requirements:
|
65
37
|
- - "~>"
|
66
38
|
- !ruby/object:Gem::Version
|
67
|
-
version: '3.
|
39
|
+
version: '3.14'
|
68
40
|
- - ">="
|
69
41
|
- !ruby/object:Gem::Version
|
70
|
-
version: 3.
|
42
|
+
version: 3.14.1
|
71
43
|
type: :runtime
|
72
44
|
prerelease: false
|
73
45
|
version_requirements: !ruby/object:Gem::Requirement
|
74
46
|
requirements:
|
75
47
|
- - "~>"
|
76
48
|
- !ruby/object:Gem::Version
|
77
|
-
version: '3.
|
49
|
+
version: '3.14'
|
78
50
|
- - ">="
|
79
51
|
- !ruby/object:Gem::Version
|
80
|
-
version: 3.
|
52
|
+
version: 3.14.1
|
81
53
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
54
|
+
name: appium_lib_core
|
83
55
|
requirement: !ruby/object:Gem::Requirement
|
84
56
|
requirements:
|
85
57
|
- - "~>"
|
86
58
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
59
|
+
version: 3.10.1
|
88
60
|
- - ">="
|
89
61
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
62
|
+
version: 3.10.1
|
91
63
|
type: :runtime
|
92
64
|
prerelease: false
|
93
65
|
version_requirements: !ruby/object:Gem::Requirement
|
94
66
|
requirements:
|
95
67
|
- - "~>"
|
96
68
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
69
|
+
version: 3.10.1
|
98
70
|
- - ">="
|
99
71
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
72
|
+
version: 3.10.1
|
101
73
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
74
|
+
name: httparty
|
103
75
|
requirement: !ruby/object:Gem::Requirement
|
104
76
|
requirements:
|
105
77
|
- - "~>"
|
106
78
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
79
|
+
version: 0.13.7
|
108
80
|
- - ">="
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
82
|
+
version: 0.13.7
|
111
83
|
type: :runtime
|
112
84
|
prerelease: false
|
113
85
|
version_requirements: !ruby/object:Gem::Requirement
|
114
86
|
requirements:
|
115
87
|
- - "~>"
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
89
|
+
version: 0.13.7
|
118
90
|
- - ">="
|
119
91
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
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
|
92
|
+
version: 0.13.7
|
135
93
|
description: Behavior driven development (BDD) approach to write automation test script
|
136
|
-
to test
|
137
|
-
email:
|
138
|
-
- anhpq.info@gmail.com
|
94
|
+
to test Web and Android applications.
|
95
|
+
email: anh.pham@infodation.vn
|
139
96
|
executables:
|
140
97
|
- itms_automation
|
141
98
|
extensions: []
|
142
99
|
extra_rdoc_files: []
|
143
100
|
files:
|
144
|
-
- bin/console
|
145
|
-
- bin/documentation_generator.rb
|
146
101
|
- bin/generate.rb
|
147
102
|
- bin/helper.rb
|
148
103
|
- bin/itms_automation
|
149
|
-
-
|
104
|
+
- doc/installation.md
|
105
|
+
- doc/itms-automation-API.md
|
106
|
+
- doc/itms-automation-help.md
|
107
|
+
- example/android/android_app/android_app_calculator.zip
|
108
|
+
- example/android/android_app/android_app_calculator/AndroidCalculator.apk
|
109
|
+
- example/android/android_app/android_app_calculator/features/calculator.feature
|
110
|
+
- example/android/android_app/android_app_calculator/features/my_first.feature
|
111
|
+
- example/android/android_app/android_app_calculator/features/screenshots/test.png
|
112
|
+
- example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb
|
113
|
+
- example/android/android_app/android_app_calculator/features/support/env.rb
|
114
|
+
- example/android/android_app/android_app_calculator/features/support/hooks.rb
|
115
|
+
- example/android/android_web/android_web_gmail_login.zip
|
116
|
+
- example/android/android_web/android_web_gmail_login/features/gmail_login.feature
|
117
|
+
- example/android/android_web/android_web_gmail_login/features/my_first.feature
|
118
|
+
- example/android/android_web/android_web_gmail_login/features/screenshots/test.png
|
119
|
+
- example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb
|
120
|
+
- example/android/android_web/android_web_gmail_login/features/support/env.rb
|
121
|
+
- example/android/android_web/android_web_gmail_login/features/support/hooks.rb
|
122
|
+
- example/desktop web/desktop_web_gmail_login.zip
|
123
|
+
- example/desktop web/desktop_web_gmail_login/features/gmail_login.feature
|
124
|
+
- example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature
|
125
|
+
- example/desktop web/desktop_web_gmail_login/features/my_first.feature
|
126
|
+
- example/desktop web/desktop_web_gmail_login/features/screenshots/test.png
|
127
|
+
- example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb
|
128
|
+
- example/desktop web/desktop_web_gmail_login/features/support/env.rb
|
129
|
+
- example/desktop web/desktop_web_gmail_login/features/support/hooks.rb
|
130
|
+
- features-skeleton/my_first.feature
|
131
|
+
- features-skeleton/screenshots/test.png
|
132
|
+
- features-skeleton/step_definitions/custom_steps.rb
|
133
|
+
- features-skeleton/step_definitions/repositories/project_object.yml
|
134
|
+
- features-skeleton/support/env.rb
|
135
|
+
- features-skeleton/support/hooks.rb
|
150
136
|
- lib/itms_automation.rb
|
151
|
-
- lib/itms_automation/
|
152
|
-
- lib/itms_automation/
|
153
|
-
- lib/itms_automation/
|
154
|
-
- lib/itms_automation/
|
137
|
+
- lib/itms_automation/assertion_steps.rb
|
138
|
+
- lib/itms_automation/click_elements_steps.rb
|
139
|
+
- lib/itms_automation/configuration_steps.rb
|
140
|
+
- lib/itms_automation/input_steps.rb
|
141
|
+
- lib/itms_automation/javascript_handling_steps.rb
|
142
|
+
- lib/itms_automation/methods/assertion_methods.rb
|
143
|
+
- lib/itms_automation/methods/click_elements_methods.rb
|
144
|
+
- lib/itms_automation/methods/configuration_methods.rb
|
145
|
+
- lib/itms_automation/methods/error_handling_methods.rb
|
146
|
+
- lib/itms_automation/methods/input_methods.rb
|
147
|
+
- lib/itms_automation/methods/javascript_handling_methods.rb
|
148
|
+
- lib/itms_automation/methods/misc_methods.rb
|
149
|
+
- lib/itms_automation/methods/navigate_methods.rb
|
150
|
+
- lib/itms_automation/methods/progress_methods.rb
|
151
|
+
- lib/itms_automation/methods/required_files.rb
|
152
|
+
- lib/itms_automation/methods/screenshot_methods.rb
|
153
|
+
- lib/itms_automation/navigation_steps.rb
|
154
|
+
- lib/itms_automation/progress_steps.rb
|
155
|
+
- lib/itms_automation/screenshot_steps.rb
|
155
156
|
- lib/itms_automation/version.rb
|
156
|
-
|
157
|
-
- project/Gemfile
|
158
|
-
- project/README.md
|
159
|
-
- project/Rakefile
|
160
|
-
- project/config/chrome_headless_options.yaml
|
161
|
-
- project/config/chrome_options.yaml
|
162
|
-
- project/config/firefox_headless_options.yaml
|
163
|
-
- project/config/firefox_options.yaml
|
164
|
-
- project/config/ie_options.yaml
|
165
|
-
- project/config/remote_options.yaml
|
166
|
-
- project/config/safari_options.yaml
|
167
|
-
- project/cucumber.yml
|
168
|
-
- project/features/TestSuite/WebGUI.feature
|
169
|
-
- project/features/step_definitions/lib_steps/steps_definition.rb
|
170
|
-
- project/features/step_definitions/repositories/project_object.yml
|
171
|
-
- project/features/support/env.rb
|
172
|
-
- project/features/support/hooks.rb
|
173
|
-
homepage: http://rubygems.org/gems/itms_automation
|
157
|
+
homepage: http://infodation.nl/
|
174
158
|
licenses:
|
175
159
|
- MIT
|
176
160
|
metadata: {}
|
@@ -182,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
166
|
requirements:
|
183
167
|
- - ">="
|
184
168
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
169
|
+
version: 1.9.3
|
186
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
171
|
requirements:
|
188
172
|
- - ">="
|
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
|