ruby_raider 3.1.0 → 3.2.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/README.md +0 -1
- data/lib/commands/utility_commands.rb +0 -9
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -8
- data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -8
- data/lib/generators/helper_generator.rb +0 -7
- data/lib/generators/templates/common/partials/web_config.tt +1 -8
- data/lib/generators/templates/helpers/browser_helper.tt +0 -5
- data/lib/generators/templates/helpers/partials/selenium_driver.tt +0 -5
- data/lib/generators/templates/helpers/spec_helper.tt +0 -5
- data/lib/generators/templates/helpers/test_helper.tt +0 -7
- data/lib/utilities/utilities.rb +0 -7
- data/lib/version +1 -1
- data/sig/commands/utility_commands.rbs +0 -1
- data/sig/generators/helper_generator.rbs +0 -1
- data/sig/utilities/utilities.rbs +0 -1
- data/spec/integration/content/config_content_spec.rb +0 -36
- data/spec/integration/content/helper_content_spec.rb +0 -46
- data/spec/integration/end_to_end_features_spec.rb +1 -25
- metadata +1 -6
- data/lib/generators/templates/common/ruby_version.tt +0 -1
- data/lib/generators/templates/helpers/debug_helper.tt +0 -190
- data/lib/generators/templates/helpers/partials/debug_diagnostics.tt +0 -5
- data/lib/generators/templates/helpers/partials/debug_start.tt +0 -5
- data/spec/integration/generators/debug_helper_spec.rb +0 -48
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0842e723974ba7cc29e671c8e566b1287f91bcda6a8615003f6504758a921faf'
|
|
4
|
+
data.tar.gz: 6aa352dc3a9e74d15c3ffa77e705165de92533adaf071d9dd00dfa492951161f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be15c65fb5974c102e822375e064427d6deff7d727cc4265074ab6006f6f6c2454ccf3d4456d81e10cdc686acb0fec70d2a6695573d6b066fd871b8b9c44d31d
|
|
7
|
+
data.tar.gz: d210f0c563e7a8d89a654a95b5d93022f1a35be4814587e9bc7221342394a10c07c7ce148047bc6ee715a7b045c0d79280deef47a42be485998fc89a2ee9d54b
|
data/README.md
CHANGED
|
@@ -133,7 +133,6 @@ raider u raid # Run all tests
|
|
|
133
133
|
raider u timeout [SECONDS] # Set test timeout
|
|
134
134
|
raider u viewport [DIMENSIONS] # Set viewport size (e.g., 1920x1080)
|
|
135
135
|
raider u platform [PLATFORM] # Set platform for cross-platform tests
|
|
136
|
-
raider u debug [on/off] # Toggle debug mode
|
|
137
136
|
raider u start_appium # Start Appium server
|
|
138
137
|
raider u desktop # Download Raider Desktop
|
|
139
138
|
```
|
|
@@ -92,15 +92,6 @@ class UtilityCommands < Thor
|
|
|
92
92
|
Utilities.platform = platform
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
desc 'debug [on/off]', 'Toggles debug mode for failure diagnostics and logging'
|
|
96
|
-
|
|
97
|
-
def debug(toggle)
|
|
98
|
-
enabled = %w[on true 1 yes].include?(toggle.downcase)
|
|
99
|
-
Utilities.debug = enabled
|
|
100
|
-
state = enabled ? 'enabled' : 'disabled'
|
|
101
|
-
say "Debug mode #{state}", :green
|
|
102
|
-
end
|
|
103
|
-
|
|
104
95
|
desc 'start_appium', 'It starts the appium server'
|
|
105
96
|
def start_appium
|
|
106
97
|
system 'appium --base-path /wd/hub'
|
|
@@ -7,7 +7,6 @@ require 'rspec'
|
|
|
7
7
|
require 'tmpdir'
|
|
8
8
|
require 'yaml'
|
|
9
9
|
require_relative '../../helpers/allure_helper'
|
|
10
|
-
require_relative '../../helpers/debug_helper'
|
|
11
10
|
|
|
12
11
|
Before do
|
|
13
12
|
viewport = YAML.load_file('config/config.yml')['viewport']
|
|
@@ -16,16 +15,9 @@ Before do
|
|
|
16
15
|
else
|
|
17
16
|
driver.manage.window.maximize
|
|
18
17
|
end
|
|
19
|
-
DebugHelper.enable_network_logging(driver)
|
|
20
|
-
@debug_action_logger = DebugHelper.action_logger_for(self.class.to_s)
|
|
21
18
|
end
|
|
22
19
|
|
|
23
20
|
After do |scenario|
|
|
24
|
-
if scenario.failed?
|
|
25
|
-
DebugHelper.capture_failure_diagnostics(driver, scenario.name, exception: scenario.exception)
|
|
26
|
-
DebugHelper.capture_network_logs(DebugHelper.resolve_selenium_driver(driver), DebugHelper.sanitize(scenario.name))
|
|
27
|
-
end
|
|
28
|
-
@debug_action_logger&.close
|
|
29
21
|
Dir.mktmpdir do |temp_folder|
|
|
30
22
|
screenshot = driver.save_screenshot("#{temp_folder}/#{scenario.name}.png")
|
|
31
23
|
AllureHelper.add_screenshot(scenario.name, screenshot)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require 'tmpdir'
|
|
4
4
|
require 'yaml'
|
|
5
5
|
require_relative '../../helpers/allure_helper'
|
|
6
|
-
require_relative '../../helpers/debug_helper'
|
|
7
6
|
|
|
8
7
|
Before do
|
|
9
8
|
viewport = YAML.load_file('config/config.yml')['viewport']
|
|
@@ -12,16 +11,9 @@ Before do
|
|
|
12
11
|
else
|
|
13
12
|
browser.window.maximize
|
|
14
13
|
end
|
|
15
|
-
DebugHelper.enable_network_logging(browser)
|
|
16
|
-
@debug_action_logger = DebugHelper.action_logger_for(self.class.to_s)
|
|
17
14
|
end
|
|
18
15
|
|
|
19
16
|
After do |scenario|
|
|
20
|
-
if scenario.failed?
|
|
21
|
-
DebugHelper.capture_failure_diagnostics(browser, scenario.name, exception: scenario.exception)
|
|
22
|
-
DebugHelper.capture_network_logs(DebugHelper.resolve_selenium_driver(browser), DebugHelper.sanitize(scenario.name))
|
|
23
|
-
end
|
|
24
|
-
@debug_action_logger&.close
|
|
25
17
|
Dir.mktmpdir do |temp_folder|
|
|
26
18
|
screenshot = browser.screenshot.save("#{temp_folder}/#{scenario.name}.png")
|
|
27
19
|
AllureHelper.add_screenshot(scenario.name, screenshot)
|
|
@@ -8,7 +8,6 @@ class HelpersGenerator < Generator
|
|
|
8
8
|
generate_driver_helper
|
|
9
9
|
generate_appium_helper
|
|
10
10
|
generate_allure_helper
|
|
11
|
-
generate_debug_helper
|
|
12
11
|
generate_spec_helper
|
|
13
12
|
end
|
|
14
13
|
|
|
@@ -42,10 +41,4 @@ class HelpersGenerator < Generator
|
|
|
42
41
|
template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
|
|
43
42
|
end
|
|
44
43
|
|
|
45
|
-
def generate_debug_helper
|
|
46
|
-
return unless web?
|
|
47
|
-
|
|
48
|
-
template('helpers/debug_helper.tt', "#{name}/helpers/debug_helper.rb")
|
|
49
|
-
end
|
|
50
|
-
|
|
51
44
|
end
|
|
@@ -13,11 +13,4 @@ browser_arguments:
|
|
|
13
13
|
- search-engine-choice-country
|
|
14
14
|
firefox:
|
|
15
15
|
- acceptInsecureCerts
|
|
16
|
-
- no-sandbox
|
|
17
|
-
|
|
18
|
-
debug:
|
|
19
|
-
enabled: false # also toggled by DEBUG=true env var
|
|
20
|
-
console_logs: true # capture browser console logs on failure
|
|
21
|
-
action_logging: true # log driver actions with timestamps
|
|
22
|
-
network_logging: true # capture HTTP requests on failure (Chrome/Edge only)
|
|
23
|
-
log_dir: 'debug_logs'
|
|
16
|
+
- no-sandbox
|
|
@@ -23,11 +23,6 @@ module BrowserHelper
|
|
|
23
23
|
args += ['--headless'] if (ENV['HEADLESS'] || config['headless']) && !args.include?('--headless')
|
|
24
24
|
capitalized = browser_name == 'ie' ? browser_name.upcase : browser_name.capitalize
|
|
25
25
|
browser_options = "Selenium::WebDriver::#{capitalized}::Options".constantize.new(args:)
|
|
26
|
-
debug_cfg = config['debug'] || {}
|
|
27
|
-
if %w[chrome edge msedge].include?(browser_name.downcase) &&
|
|
28
|
-
(debug_cfg.fetch('enabled', false) || ENV['DEBUG']&.downcase == 'true')
|
|
29
|
-
browser_options.add_option('goog:loggingPrefs', { browser: 'ALL', performance: 'ALL' })
|
|
30
|
-
end
|
|
31
26
|
Watir::Browser.new(browser_name.to_sym, options: browser_options)
|
|
32
27
|
end
|
|
33
28
|
end
|
|
@@ -17,10 +17,5 @@
|
|
|
17
17
|
browser = load_browser == 'ie' ? load_browser.upcase : load_browser.capitalize
|
|
18
18
|
options = "Selenium::WebDriver::#{browser}::Options".constantize.new
|
|
19
19
|
browser_arguments(*opts).each { |arg| options.add_argument(arg) }
|
|
20
|
-
debug_cfg = @config['debug'] || {}
|
|
21
|
-
if %w[chrome edge msedge].include?(@config['browser'].to_s.downcase) &&
|
|
22
|
-
(debug_cfg.fetch('enabled', false) || ENV['DEBUG']&.downcase == 'true')
|
|
23
|
-
options.add_option('goog:loggingPrefs', { browser: 'ALL', performance: 'ALL' })
|
|
24
|
-
end
|
|
25
20
|
options
|
|
26
21
|
end
|
|
@@ -7,7 +7,6 @@ require 'rspec'
|
|
|
7
7
|
require 'rspec/retry'
|
|
8
8
|
require 'tmpdir'
|
|
9
9
|
require_relative 'allure_helper'
|
|
10
|
-
require_relative 'debug_helper'
|
|
11
10
|
<%- if watir? -%>
|
|
12
11
|
require_relative 'browser_helper'
|
|
13
12
|
<%- else -%>
|
|
@@ -48,17 +47,13 @@ module SpecHelper
|
|
|
48
47
|
browser.window.maximize
|
|
49
48
|
end
|
|
50
49
|
<%- end -%>
|
|
51
|
-
<%= partial('debug_start', strip: true) %>
|
|
52
|
-
@debug_action_logger = DebugHelper.action_logger_for(self.class.description)
|
|
53
50
|
end
|
|
54
51
|
|
|
55
52
|
config.after(:each) do |example|
|
|
56
53
|
example_name = example.description
|
|
57
54
|
if example.exception
|
|
58
55
|
@_exception = example.exception
|
|
59
|
-
<%= partial('debug_diagnostics', strip: true) %>
|
|
60
56
|
end
|
|
61
|
-
@debug_action_logger&.close
|
|
62
57
|
Dir.mktmpdir do |temp_folder|
|
|
63
58
|
<%= partial('screenshot', strip: true) %>
|
|
64
59
|
AllureHelper.add_screenshot(example_name, screenshot)
|
|
@@ -11,7 +11,6 @@ require_relative 'allure_helper'
|
|
|
11
11
|
<%- unless skip_video? -%>
|
|
12
12
|
require_relative 'video_helper'
|
|
13
13
|
<%- end -%>
|
|
14
|
-
require_relative 'debug_helper'
|
|
15
14
|
<%- if watir? -%>
|
|
16
15
|
require_relative 'browser_helper'
|
|
17
16
|
<%- elsif capybara? -%>
|
|
@@ -64,16 +63,10 @@ module TestHelper
|
|
|
64
63
|
<%= partial('video_start', strip: true) %>
|
|
65
64
|
@video_recorder&.start(self.class.name)
|
|
66
65
|
<%- end -%>
|
|
67
|
-
<%= partial('debug_start', strip: true) %>
|
|
68
|
-
@debug_action_logger = DebugHelper.action_logger_for(self.class.name)
|
|
69
66
|
end
|
|
70
67
|
|
|
71
68
|
def teardown
|
|
72
69
|
example_name = name
|
|
73
|
-
unless passed?
|
|
74
|
-
<%= partial('debug_diagnostics', strip: true) %>
|
|
75
|
-
end
|
|
76
|
-
@debug_action_logger&.close
|
|
77
70
|
<%- unless skip_video? -%>
|
|
78
71
|
video_file = @video_recorder&.stop
|
|
79
72
|
<%- if allure_reporter? -%>
|
data/lib/utilities/utilities.rb
CHANGED
|
@@ -62,13 +62,6 @@ module Utilities
|
|
|
62
62
|
set('headless', enabled)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
def debug=(enabled)
|
|
66
|
-
reload_config
|
|
67
|
-
@config['debug'] ||= {}
|
|
68
|
-
@config['debug']['enabled'] = enabled
|
|
69
|
-
overwrite_yaml
|
|
70
|
-
end
|
|
71
|
-
|
|
72
65
|
# Set multiple config keys in a single YAML write.
|
|
73
66
|
# Usage: Utilities.batch_update(browser: 'chrome', timeout: 30)
|
|
74
67
|
def batch_update(**settings)
|
data/lib/version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.2.0
|
data/sig/utilities/utilities.rbs
CHANGED
|
@@ -13,7 +13,6 @@ module Utilities
|
|
|
13
13
|
def self?.platform=: (String platform) -> void
|
|
14
14
|
def self?.browser_options=: (Array[String] opts) -> void
|
|
15
15
|
def self?.delete_browser_options: () -> void
|
|
16
|
-
def self?.debug=: (bool enabled) -> void
|
|
17
16
|
def self?.batch_update: (**untyped settings) -> void
|
|
18
17
|
def self?.run: (?String? opts) -> void
|
|
19
18
|
def self?.parallel_run: (?String? opts, ?untyped? _settings) -> void
|
|
@@ -51,60 +51,24 @@ describe 'Config file content' do
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
shared_examples 'config with debug section' do |project_name|
|
|
55
|
-
subject(:config_content) { read_generated(project_name, 'config/config.yml') }
|
|
56
|
-
|
|
57
|
-
let(:config) { YAML.safe_load(config_content, permitted_classes: [Symbol]) }
|
|
58
|
-
|
|
59
|
-
it 'has debug section' do
|
|
60
|
-
expect(config).to have_key('debug')
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'has debug enabled key defaulting to false' do
|
|
64
|
-
expect(config['debug']['enabled']).to be false
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'has debug console_logs key' do
|
|
68
|
-
expect(config['debug']['console_logs']).to be true
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'has debug action_logging key' do
|
|
72
|
-
expect(config['debug']['action_logging']).to be true
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'has debug network_logging key' do
|
|
76
|
-
expect(config['debug']['network_logging']).to be true
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'has debug log_dir key' do
|
|
80
|
-
expect(config['debug']['log_dir']).to eq('debug_logs')
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
54
|
# --- Web config per automation ---
|
|
85
55
|
|
|
86
56
|
context 'with rspec and selenium' do
|
|
87
57
|
name = "#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}"
|
|
88
58
|
include_examples 'valid web config', name
|
|
89
59
|
include_examples 'selenium config with timeout', name
|
|
90
|
-
|
|
91
|
-
include_examples 'config with debug section', name
|
|
92
60
|
end
|
|
93
61
|
|
|
94
62
|
context 'with rspec and watir' do
|
|
95
63
|
name = "#{FrameworkIndex::RSPEC}_#{AutomationIndex::WATIR}"
|
|
96
64
|
include_examples 'valid web config', name
|
|
97
65
|
include_examples 'config without driver_options', name
|
|
98
|
-
|
|
99
|
-
include_examples 'config with debug section', name
|
|
100
66
|
end
|
|
101
67
|
|
|
102
68
|
context 'with cucumber and selenium' do
|
|
103
69
|
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}"
|
|
104
70
|
include_examples 'valid web config', name
|
|
105
71
|
include_examples 'selenium config with timeout', name
|
|
106
|
-
|
|
107
|
-
include_examples 'config with debug section', name
|
|
108
72
|
end
|
|
109
73
|
|
|
110
74
|
# --- Mobile config ---
|
|
@@ -155,44 +155,6 @@ describe 'Helper file content' do
|
|
|
155
155
|
end
|
|
156
156
|
end
|
|
157
157
|
|
|
158
|
-
# --- Debug helper ---
|
|
159
|
-
|
|
160
|
-
shared_examples 'valid debug helper' do |project_name|
|
|
161
|
-
subject(:helper) { read_generated(project_name, 'helpers/debug_helper.rb') }
|
|
162
|
-
|
|
163
|
-
it 'has frozen_string_literal' do
|
|
164
|
-
expect(helper).to have_frozen_string_literal
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it 'has valid Ruby syntax' do
|
|
168
|
-
expect(helper).to have_valid_ruby_syntax
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
it 'defines DebugHelper module' do
|
|
172
|
-
expect(helper).to match(/module DebugHelper/)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it 'defines enabled? method' do
|
|
176
|
-
expect(helper).to include('def enabled?')
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it 'defines capture_failure_diagnostics method' do
|
|
180
|
-
expect(helper).to include('def capture_failure_diagnostics')
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
it 'defines ActionLogger class' do
|
|
184
|
-
expect(helper).to include('class ActionLogger')
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it 'defines NullActionLogger class' do
|
|
188
|
-
expect(helper).to include('class NullActionLogger')
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it 'reads config from YAML' do
|
|
192
|
-
expect(helper).to include('YAML.load_file')
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
158
|
# --- RSpec + automation contexts ---
|
|
197
159
|
|
|
198
160
|
context 'with rspec and selenium' do
|
|
@@ -202,8 +164,6 @@ describe 'Helper file content' do
|
|
|
202
164
|
it_behaves_like 'valid spec helper', name
|
|
203
165
|
it_behaves_like 'selenium spec helper', name
|
|
204
166
|
it_behaves_like 'valid allure helper', name
|
|
205
|
-
|
|
206
|
-
it_behaves_like 'valid debug helper', name
|
|
207
167
|
end
|
|
208
168
|
|
|
209
169
|
context 'with rspec and watir' do
|
|
@@ -212,8 +172,6 @@ describe 'Helper file content' do
|
|
|
212
172
|
it_behaves_like 'valid spec helper', name
|
|
213
173
|
it_behaves_like 'watir spec helper', name
|
|
214
174
|
it_behaves_like 'valid allure helper', name
|
|
215
|
-
|
|
216
|
-
it_behaves_like 'valid debug helper', name
|
|
217
175
|
end
|
|
218
176
|
|
|
219
177
|
# --- Cucumber + automation contexts (no spec_helper/test_helper) ---
|
|
@@ -223,16 +181,12 @@ describe 'Helper file content' do
|
|
|
223
181
|
it_behaves_like 'valid driver helper', name
|
|
224
182
|
it_behaves_like 'selenium driver helper', name
|
|
225
183
|
it_behaves_like 'valid allure helper', name
|
|
226
|
-
|
|
227
|
-
it_behaves_like 'valid debug helper', name
|
|
228
184
|
end
|
|
229
185
|
|
|
230
186
|
context 'with cucumber and watir' do
|
|
231
187
|
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}"
|
|
232
188
|
it_behaves_like 'valid browser helper', name
|
|
233
189
|
it_behaves_like 'valid allure helper', name
|
|
234
|
-
|
|
235
|
-
it_behaves_like 'valid debug helper', name
|
|
236
190
|
end
|
|
237
191
|
|
|
238
192
|
# --- Mobile contexts (with AppiumRecorder) ---
|
|
@@ -7,7 +7,7 @@ require_relative '../../lib/scaffolding/scaffolding'
|
|
|
7
7
|
require 'timeout'
|
|
8
8
|
require 'open3'
|
|
9
9
|
|
|
10
|
-
# End-to-end tests for features (retry, tags, addons, CI,
|
|
10
|
+
# End-to-end tests for features (retry, tags, addons, CI, etc.)
|
|
11
11
|
# These tests generate complete projects with feature flags and verify they are executable.
|
|
12
12
|
describe 'End-to-End Feature Validation' do
|
|
13
13
|
include ContentHelper
|
|
@@ -265,28 +265,4 @@ describe 'End-to-End Feature Validation' do
|
|
|
265
265
|
end
|
|
266
266
|
end
|
|
267
267
|
|
|
268
|
-
# --- Feature: Debug helper ---
|
|
269
|
-
|
|
270
|
-
context 'Debug helper generation' do
|
|
271
|
-
it 'web projects include debug_helper.rb' do
|
|
272
|
-
expect(File).to exist("#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}/helpers/debug_helper.rb")
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
it 'debug helper has valid Ruby syntax' do
|
|
276
|
-
content = File.read("#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}/helpers/debug_helper.rb")
|
|
277
|
-
expect { RubyVM::InstructionSequence.compile(content) }.not_to raise_error
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
it 'debug helper defines DebugHelper module' do
|
|
281
|
-
content = File.read("#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}/helpers/debug_helper.rb")
|
|
282
|
-
expect(content).to include('module DebugHelper')
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
it 'config.yml includes debug section' do
|
|
286
|
-
config = YAML.load_file("#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}/config/config.yml")
|
|
287
|
-
expect(config).to have_key('debug')
|
|
288
|
-
expect(config['debug']['enabled']).to be false
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
268
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_raider
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Agustin Pequeno
|
|
@@ -232,18 +232,14 @@ files:
|
|
|
232
232
|
- lib/generators/templates/common/reek.tt
|
|
233
233
|
- lib/generators/templates/common/rspec.tt
|
|
234
234
|
- lib/generators/templates/common/rubocop.tt
|
|
235
|
-
- lib/generators/templates/common/ruby_version.tt
|
|
236
235
|
- lib/generators/templates/helpers/allure_helper.tt
|
|
237
236
|
- lib/generators/templates/helpers/appium_helper.tt
|
|
238
237
|
- lib/generators/templates/helpers/browser_helper.tt
|
|
239
|
-
- lib/generators/templates/helpers/debug_helper.tt
|
|
240
238
|
- lib/generators/templates/helpers/driver_helper.tt
|
|
241
239
|
- lib/generators/templates/helpers/partials/allure_imports.tt
|
|
242
240
|
- lib/generators/templates/helpers/partials/allure_requirements.tt
|
|
243
241
|
- lib/generators/templates/helpers/partials/appium_driver.tt
|
|
244
242
|
- lib/generators/templates/helpers/partials/browserstack_config.tt
|
|
245
|
-
- lib/generators/templates/helpers/partials/debug_diagnostics.tt
|
|
246
|
-
- lib/generators/templates/helpers/partials/debug_start.tt
|
|
247
243
|
- lib/generators/templates/helpers/partials/driver_and_options.tt
|
|
248
244
|
- lib/generators/templates/helpers/partials/quit_driver.tt
|
|
249
245
|
- lib/generators/templates/helpers/partials/screenshot.tt
|
|
@@ -322,7 +318,6 @@ files:
|
|
|
322
318
|
- spec/integration/generators/common_generator_spec.rb
|
|
323
319
|
- spec/integration/generators/config_features_spec.rb
|
|
324
320
|
- spec/integration/generators/cucumber_generator_spec.rb
|
|
325
|
-
- spec/integration/generators/debug_helper_spec.rb
|
|
326
321
|
- spec/integration/generators/github_generator_spec.rb
|
|
327
322
|
- spec/integration/generators/helpers_generator_spec.rb
|
|
328
323
|
- spec/integration/generators/rspec_generator_spec.rb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= ruby_version %>
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
require 'yaml'
|
|
5
|
-
require 'logger'
|
|
6
|
-
require 'json'
|
|
7
|
-
|
|
8
|
-
module DebugHelper
|
|
9
|
-
LOG_DIR = 'debug_logs'
|
|
10
|
-
|
|
11
|
-
module_function
|
|
12
|
-
|
|
13
|
-
# --- Configuration ---
|
|
14
|
-
|
|
15
|
-
def config
|
|
16
|
-
@config ||= begin
|
|
17
|
-
yml = YAML.load_file('config/config.yml')
|
|
18
|
-
yml['debug'] || {}
|
|
19
|
-
rescue StandardError
|
|
20
|
-
{}
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def enabled?
|
|
25
|
-
ENV['DEBUG']&.downcase == 'true' || config.fetch('enabled', false)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def console_logs?
|
|
29
|
-
enabled? && config.fetch('console_logs', true)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def action_logging?
|
|
33
|
-
enabled? && config.fetch('action_logging', true)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def network_logging?
|
|
37
|
-
enabled? && config.fetch('network_logging', true)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def log_dir
|
|
41
|
-
config.fetch('log_dir', LOG_DIR)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def ensure_log_dir
|
|
45
|
-
FileUtils.mkdir_p(log_dir)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# --- Driver Resolution ---
|
|
49
|
-
|
|
50
|
-
def resolve_selenium_driver(obj)
|
|
51
|
-
if obj.respond_to?(:driver) && !obj.is_a?(Selenium::WebDriver::Driver)
|
|
52
|
-
obj.driver
|
|
53
|
-
elsif obj.respond_to?(:browser) && obj.browser.respond_to?(:driver)
|
|
54
|
-
obj.browser.driver
|
|
55
|
-
else
|
|
56
|
-
obj
|
|
57
|
-
end
|
|
58
|
-
rescue StandardError
|
|
59
|
-
obj
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# --- Failure Diagnostics (returns structured hash for desktop integration) ---
|
|
63
|
-
|
|
64
|
-
def capture_failure_diagnostics(driver_or_browser, test_name, exception: nil)
|
|
65
|
-
return {} unless enabled?
|
|
66
|
-
|
|
67
|
-
ensure_log_dir
|
|
68
|
-
sel_driver = resolve_selenium_driver(driver_or_browser)
|
|
69
|
-
safe_name = sanitize(test_name)
|
|
70
|
-
diagnostics = { test_name: test_name, timestamp: Time.now.iso8601 }
|
|
71
|
-
|
|
72
|
-
diagnostics[:url] = sel_driver.current_url rescue 'unknown'
|
|
73
|
-
diagnostics[:title] = sel_driver.title rescue 'unknown'
|
|
74
|
-
|
|
75
|
-
if exception
|
|
76
|
-
diagnostics[:error_message] = exception.message
|
|
77
|
-
diagnostics[:error_class] = exception.class.name
|
|
78
|
-
diagnostics[:stack_trace] = exception.backtrace&.first(20) || []
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
diagnostics[:console_logs] = capture_console_logs(sel_driver) if console_logs?
|
|
82
|
-
diagnostics[:network_log_path] = capture_network_logs(sel_driver, safe_name) if network_logging?
|
|
83
|
-
|
|
84
|
-
# HTML snapshot
|
|
85
|
-
html_path = File.join(log_dir, "#{safe_name}_page.html")
|
|
86
|
-
File.write(html_path, sel_driver.page_source) rescue nil
|
|
87
|
-
diagnostics[:html_snapshot] = html_path
|
|
88
|
-
|
|
89
|
-
# Write diagnostics JSON (desktop app reads this)
|
|
90
|
-
summary_path = File.join(log_dir, "#{safe_name}_diagnostics.json")
|
|
91
|
-
File.write(summary_path, JSON.pretty_generate(diagnostics))
|
|
92
|
-
diagnostics[:summary_path] = summary_path
|
|
93
|
-
|
|
94
|
-
diagnostics
|
|
95
|
-
rescue StandardError => e
|
|
96
|
-
warn "[debug] Failed to capture diagnostics: #{e.message}"
|
|
97
|
-
{}
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# --- Console Log Capture ---
|
|
101
|
-
|
|
102
|
-
def capture_console_logs(sel_driver)
|
|
103
|
-
return [] unless chrome_or_edge?(sel_driver)
|
|
104
|
-
|
|
105
|
-
sel_driver.logs.get(:browser).map { |entry| { level: entry.level, message: entry.message, timestamp: entry.timestamp } }
|
|
106
|
-
rescue StandardError
|
|
107
|
-
[]
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# --- Action Logger ---
|
|
111
|
-
|
|
112
|
-
class ActionLogger
|
|
113
|
-
def initialize(test_name)
|
|
114
|
-
DebugHelper.ensure_log_dir
|
|
115
|
-
log_path = File.join(DebugHelper.log_dir, "#{DebugHelper.sanitize(test_name)}_actions.log")
|
|
116
|
-
@logger = Logger.new(log_path)
|
|
117
|
-
@logger.formatter = proc { |severity, datetime, _progname, msg|
|
|
118
|
-
"[#{datetime.strftime('%H:%M:%S.%L')}] #{severity}: #{msg}\n"
|
|
119
|
-
}
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def log(action, details = '')
|
|
123
|
-
@logger.info("#{action} #{details}".strip)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def close
|
|
127
|
-
@logger.close
|
|
128
|
-
rescue StandardError
|
|
129
|
-
nil
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
class NullActionLogger
|
|
134
|
-
def log(_action, _details = '') = nil
|
|
135
|
-
def close = nil
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
def action_logger_for(test_name)
|
|
139
|
-
action_logging? ? ActionLogger.new(test_name) : NullActionLogger.new
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
# --- Network Logging Setup ---
|
|
143
|
-
|
|
144
|
-
def enable_network_logging(driver_or_browser)
|
|
145
|
-
return unless network_logging?
|
|
146
|
-
|
|
147
|
-
sel_driver = resolve_selenium_driver(driver_or_browser)
|
|
148
|
-
return unless chrome_or_edge?(sel_driver)
|
|
149
|
-
|
|
150
|
-
sel_driver.execute_cdp('Network.enable')
|
|
151
|
-
rescue StandardError => e
|
|
152
|
-
warn "[debug] Could not enable network logging: #{e.message}"
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
# --- Network Log Capture ---
|
|
156
|
-
|
|
157
|
-
def capture_network_logs(sel_driver, safe_name)
|
|
158
|
-
return unless chrome_or_edge?(sel_driver)
|
|
159
|
-
|
|
160
|
-
logs = sel_driver.logs.get(:performance)
|
|
161
|
-
return if logs.empty?
|
|
162
|
-
|
|
163
|
-
entries = logs.filter_map do |entry|
|
|
164
|
-
parsed = JSON.parse(entry.message)['message'] rescue next
|
|
165
|
-
parsed if parsed.is_a?(Hash) && parsed['method']&.start_with?('Network.')
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
return if entries.empty?
|
|
169
|
-
|
|
170
|
-
network_path = File.join(log_dir, "#{safe_name}_network.json")
|
|
171
|
-
File.write(network_path, JSON.pretty_generate(entries))
|
|
172
|
-
network_path
|
|
173
|
-
rescue StandardError => e
|
|
174
|
-
warn "[debug] Failed to capture network logs: #{e.message}"
|
|
175
|
-
nil
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
# --- Helpers ---
|
|
179
|
-
|
|
180
|
-
def chrome_or_edge?(driver)
|
|
181
|
-
browser_name = driver.capabilities[:browser_name].to_s.downcase
|
|
182
|
-
%w[chrome chromium msedge edge].any? { |b| browser_name.include?(b) }
|
|
183
|
-
rescue StandardError
|
|
184
|
-
false
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
def sanitize(name)
|
|
188
|
-
name.to_s.gsub(/[^a-zA-Z0-9_-]/, '_')[0..80]
|
|
189
|
-
end
|
|
190
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../../../lib/generators/helper_generator'
|
|
4
|
-
require_relative '../spec_helper'
|
|
5
|
-
|
|
6
|
-
describe 'Debug helper generation' do
|
|
7
|
-
shared_examples 'creates debug helper' do |name|
|
|
8
|
-
it 'creates a debug_helper.rb file' do
|
|
9
|
-
expect(File).to exist("#{name}/helpers/debug_helper.rb")
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
shared_examples 'does not create debug helper' do |name|
|
|
14
|
-
it 'does not create a debug_helper.rb file' do
|
|
15
|
-
expect(File).not_to exist("#{name}/helpers/debug_helper.rb")
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# Web frameworks should get debug_helper
|
|
20
|
-
context 'with rspec and selenium' do
|
|
21
|
-
include_examples 'creates debug helper', "#{FrameworkIndex::RSPEC}_#{AutomationIndex::SELENIUM}"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context 'with rspec and watir' do
|
|
25
|
-
include_examples 'creates debug helper', "#{FrameworkIndex::RSPEC}_#{AutomationIndex::WATIR}"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context 'with cucumber and selenium' do
|
|
29
|
-
include_examples 'creates debug helper', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context 'with cucumber and watir' do
|
|
33
|
-
include_examples 'creates debug helper', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Mobile frameworks should NOT get debug_helper
|
|
37
|
-
context 'with rspec and appium android' do
|
|
38
|
-
include_examples 'does not create debug helper', "#{FrameworkIndex::RSPEC}_#{AutomationIndex::ANDROID}"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context 'with rspec and appium ios' do
|
|
42
|
-
include_examples 'does not create debug helper', "#{FrameworkIndex::RSPEC}_#{AutomationIndex::IOS}"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'with cucumber and appium cross platform' do
|
|
46
|
-
include_examples 'does not create debug helper', "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::CROSS_PLATFORM}"
|
|
47
|
-
end
|
|
48
|
-
end
|