itms_automation 2.3 → 2.6.0
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 +108 -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 +93 -90
- 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 -702
- data/lib/itms_automation/database_steps_helper.rb +0 -125
- data/lib/itms_automation/web_steps_helper.rb +0 -844
- data/project/Gemfile +0 -3
- data/project/Gemfile.lock +0 -92
- 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 -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 -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,177 +1,180 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itms_automation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.6.0
|
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-21 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
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 3.6.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
requirements:
|
19
|
+
version: 3.1.2
|
27
20
|
- - ">="
|
28
21
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3.6'
|
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'
|
22
|
+
version: 3.1.2
|
40
23
|
type: :runtime
|
41
24
|
prerelease: false
|
42
25
|
version_requirements: !ruby/object:Gem::Requirement
|
43
26
|
requirements:
|
44
27
|
- - "~>"
|
45
28
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
29
|
+
version: 3.1.2
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.1.2
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
34
|
+
name: selenium-webdriver
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
50
36
|
requirements:
|
51
37
|
- - "~>"
|
52
38
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
39
|
+
version: '3.14'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
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
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 3.8.0
|
68
57
|
- - "~>"
|
69
58
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
59
|
+
version: 3.10.1
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::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
|
-
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 3.8.0
|
78
67
|
- - "~>"
|
79
68
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
69
|
+
version: 3.10.1
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::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
77
|
- - "~>"
|
86
78
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
79
|
+
version: 0.13.7
|
88
80
|
- - ">="
|
89
81
|
- !ruby/object:Gem::Version
|
90
|
-
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
87
|
- - "~>"
|
96
88
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
89
|
+
version: 0.13.7
|
98
90
|
- - ">="
|
99
91
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
92
|
+
version: 0.13.7
|
101
93
|
- !ruby/object:Gem::Dependency
|
102
94
|
name: report_builder
|
103
95
|
requirement: !ruby/object:Gem::Requirement
|
104
96
|
requirements:
|
105
|
-
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '1.8'
|
108
97
|
- - "~>"
|
109
98
|
- !ruby/object:Gem::Version
|
110
99
|
version: '1.8'
|
111
|
-
type: :runtime
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
100
|
- - ">="
|
116
101
|
- !ruby/object:Gem::Version
|
117
102
|
version: '1.8'
|
118
|
-
- - "~>"
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
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
103
|
type: :runtime
|
129
104
|
prerelease: false
|
130
105
|
version_requirements: !ruby/object:Gem::Requirement
|
131
106
|
requirements:
|
132
107
|
- - "~>"
|
133
108
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
109
|
+
version: '1.8'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '1.8'
|
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/my_first.feature
|
151
|
+
- features-skeleton/screenshots/test.png
|
152
|
+
- features-skeleton/step_definitions/custom_steps.rb
|
153
|
+
- features-skeleton/step_definitions/repositories/project_object.yml
|
154
|
+
- features-skeleton/support/env.rb
|
155
|
+
- features-skeleton/support/hooks.rb
|
150
156
|
- lib/itms_automation.rb
|
151
|
-
- lib/itms_automation/
|
152
|
-
- lib/itms_automation/
|
153
|
-
- lib/itms_automation/
|
154
|
-
- lib/itms_automation/
|
157
|
+
- lib/itms_automation/assertion_steps.rb
|
158
|
+
- lib/itms_automation/click_elements_steps.rb
|
159
|
+
- lib/itms_automation/configuration_steps.rb
|
160
|
+
- lib/itms_automation/input_steps.rb
|
161
|
+
- lib/itms_automation/javascript_handling_steps.rb
|
162
|
+
- lib/itms_automation/methods/assertion_methods.rb
|
163
|
+
- lib/itms_automation/methods/click_elements_methods.rb
|
164
|
+
- lib/itms_automation/methods/configuration_methods.rb
|
165
|
+
- lib/itms_automation/methods/error_handling_methods.rb
|
166
|
+
- lib/itms_automation/methods/input_methods.rb
|
167
|
+
- lib/itms_automation/methods/javascript_handling_methods.rb
|
168
|
+
- lib/itms_automation/methods/misc_methods.rb
|
169
|
+
- lib/itms_automation/methods/navigate_methods.rb
|
170
|
+
- lib/itms_automation/methods/progress_methods.rb
|
171
|
+
- lib/itms_automation/methods/required_files.rb
|
172
|
+
- lib/itms_automation/methods/screenshot_methods.rb
|
173
|
+
- lib/itms_automation/navigation_steps.rb
|
174
|
+
- lib/itms_automation/progress_steps.rb
|
175
|
+
- lib/itms_automation/screenshot_steps.rb
|
155
176
|
- lib/itms_automation/version.rb
|
156
|
-
|
157
|
-
- project/Gemfile
|
158
|
-
- project/Gemfile.lock
|
159
|
-
- project/README.md
|
160
|
-
- project/Rakefile
|
161
|
-
- project/config/chrome_headless_options.yaml
|
162
|
-
- project/config/chrome_options.yaml
|
163
|
-
- project/config/firefox_headless_options.yaml
|
164
|
-
- project/config/firefox_options.yaml
|
165
|
-
- project/config/ie_options.yaml
|
166
|
-
- project/config/remote_options.yaml
|
167
|
-
- project/config/safari_options.yaml
|
168
|
-
- project/cucumber.yml
|
169
|
-
- project/features/TestSuite/WebGUI.feature
|
170
|
-
- project/features/step_definitions/lib_steps/steps_definition.rb
|
171
|
-
- project/features/step_definitions/repositories/project_object.yml
|
172
|
-
- project/features/support/env.rb
|
173
|
-
- project/features/support/hooks.rb
|
174
|
-
homepage: http://rubygems.org/gems/itms_automation
|
177
|
+
homepage: http://infodation.nl/
|
175
178
|
licenses:
|
176
179
|
- MIT
|
177
180
|
metadata: {}
|
@@ -183,14 +186,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
186
|
requirements:
|
184
187
|
- - ">="
|
185
188
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
189
|
+
version: 1.9.3
|
187
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
191
|
requirements:
|
189
192
|
- - ">="
|
190
193
|
- !ruby/object:Gem::Version
|
191
194
|
version: '0'
|
192
195
|
requirements: []
|
193
|
-
rubygems_version: 3.
|
196
|
+
rubygems_version: 3.1.2
|
194
197
|
signing_key:
|
195
198
|
specification_version: 4
|
196
199
|
summary: SELENIUM WEBDRIVER WITH RUBY & CUCUMBER
|
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
|