ruby_raider 3.12.1 → 4.0.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/.github/workflows/runtime.yml +38 -0
- data/.github/workflows/system_tests.yml +1 -23
- data/.reek.yml +1 -0
- data/.rspec +1 -0
- data/Gemfile +2 -0
- data/README.md +17 -48
- data/RELEASE.md +22 -0
- data/bin/raider +5 -0
- data/lib/commands/scaffolding_commands.rb +2 -25
- data/lib/commands/utility_commands.rb +39 -3
- data/lib/generators/automation/automation_generator.rb +0 -5
- data/lib/generators/automation/templates/component.tt +1 -0
- data/lib/generators/automation/templates/home.tt +2 -2
- data/lib/generators/automation/templates/login.tt +6 -26
- data/lib/generators/automation/templates/page.tt +23 -18
- data/lib/generators/automation/templates/partials/home_page_selector.tt +1 -2
- data/lib/generators/automation/templates/partials/initialize_selector.tt +0 -8
- data/lib/generators/automation/templates/partials/pdp_page_selector.tt +1 -2
- data/lib/generators/automation/templates/partials/url_methods.tt +8 -2
- data/lib/generators/automation/templates/partials/visit_method.tt +0 -5
- data/lib/generators/automation/templates/pdp.tt +1 -9
- data/lib/generators/common_generator.rb +0 -2
- data/lib/generators/generator.rb +19 -17
- data/lib/generators/helper_generator.rb +25 -16
- data/lib/generators/infrastructure/templates/azure_pipelines.tt +1 -1
- data/lib/generators/infrastructure/templates/github.tt +2 -3
- data/lib/generators/infrastructure/templates/github_appium.tt +0 -8
- data/lib/generators/invoke_generators.rb +4 -23
- data/lib/generators/menu_generator.rb +1 -9
- data/lib/generators/rspec/templates/accessibility_spec.tt +1 -9
- data/lib/generators/rspec/templates/spec.tt +8 -24
- data/lib/generators/template_renderer/partial_cache.rb +3 -1
- data/lib/generators/template_renderer.rb +1 -1
- data/lib/generators/templates/common/gemfile.tt +3 -10
- data/lib/generators/templates/common/git_ignore.tt +0 -5
- data/lib/generators/templates/common/partials/mobile_config.tt +3 -1
- data/lib/generators/templates/common/partials/web_config.tt +17 -1
- data/lib/generators/templates/common/rakefile.tt +0 -15
- data/lib/generators/templates/common/read_me.tt +394 -242
- data/lib/generators/templates/common/rubocop.tt +0 -2
- data/lib/generators/templates/helpers/driver_helper.tt +30 -0
- data/lib/generators/templates/helpers/gesture_helper.tt +78 -0
- data/lib/generators/templates/helpers/network_helper.tt +521 -0
- data/lib/generators/templates/helpers/partials/quit_driver.tt +0 -2
- data/lib/generators/templates/helpers/partials/screenshot.tt +0 -2
- data/lib/generators/templates/helpers/partials/selenium_driver.tt +14 -1
- data/lib/generators/templates/helpers/screenshot_helper.tt +490 -0
- data/lib/generators/templates/helpers/spec_helper.tt +56 -27
- data/lib/generators/templates/helpers/trace_helper.tt +1242 -0
- data/lib/generators/templates/helpers/video_helper.tt +3 -8
- data/lib/ruby_raider/runtime/actionability.rb +129 -0
- data/lib/ruby_raider/runtime/actionable.rb +49 -0
- data/lib/ruby_raider/runtime/by_role.rb +55 -0
- data/lib/ruby_raider/runtime/config.rb +79 -0
- data/lib/ruby_raider/runtime/context.rb +38 -0
- data/lib/ruby_raider/runtime/errors.rb +69 -0
- data/lib/ruby_raider/runtime/finders.rb +73 -0
- data/lib/ruby_raider/runtime/js/actionability.js +134 -0
- data/lib/ruby_raider/runtime/js/role_engine.js +315 -0
- data/lib/ruby_raider/runtime/locator_converter.rb +72 -0
- data/lib/ruby_raider/runtime/matchers/base.rb +222 -0
- data/lib/ruby_raider/runtime/matchers/element.rb +183 -0
- data/lib/ruby_raider/runtime/matchers/page.rb +71 -0
- data/lib/ruby_raider/runtime/matchers/presence.rb +41 -0
- data/lib/ruby_raider/runtime/matchers/retrying_block.rb +104 -0
- data/lib/ruby_raider/runtime/observer.rb +170 -0
- data/lib/ruby_raider/runtime/role_finder.rb +83 -0
- data/lib/ruby_raider/runtime/rspec.rb +78 -0
- data/lib/ruby_raider/runtime/selectors.rb +60 -0
- data/lib/ruby_raider/runtime/strict.rb +142 -0
- data/lib/ruby_raider/runtime/wait.rb +84 -0
- data/lib/ruby_raider/runtime.rb +20 -0
- data/lib/scaffolding/name_normalizer.rb +1 -1
- data/lib/scaffolding/project_detector.rb +2 -28
- data/lib/scaffolding/scaffolding.rb +0 -20
- data/lib/scaffolding/templates/component.tt +0 -14
- data/lib/scaffolding/templates/page_object.tt +2 -14
- data/lib/scaffolding/templates/spec.tt +1 -9
- data/lib/utilities/utilities.rb +17 -8
- data/lib/version +1 -1
- data/ruby_raider.gemspec +3 -1
- data/sig/commands/scaffolding_commands.rbs +0 -2
- data/sig/commands/utility_commands.rbs +8 -0
- data/sig/generators/generator.rbs +4 -4
- data/sig/generators/helper_generator.rbs +1 -1
- data/sig/generators/menu_generator.rbs +0 -1
- data/sig/ruby_raider/runtime/actionability.rbs +25 -0
- data/sig/ruby_raider/runtime/actionable.rbs +13 -0
- data/sig/ruby_raider/runtime/by_role.rbs +15 -0
- data/sig/ruby_raider/runtime/config.rbs +26 -0
- data/sig/ruby_raider/runtime/context.rbs +12 -0
- data/sig/ruby_raider/runtime/errors.rbs +36 -0
- data/sig/ruby_raider/runtime/finders.rbs +26 -0
- data/sig/ruby_raider/runtime/locator_converter.rbs +21 -0
- data/sig/ruby_raider/runtime/matchers/base.rbs +64 -0
- data/sig/ruby_raider/runtime/matchers/element.rbs +78 -0
- data/sig/ruby_raider/runtime/matchers/page.rbs +38 -0
- data/sig/ruby_raider/runtime/matchers/presence.rbs +21 -0
- data/sig/ruby_raider/runtime/matchers/retrying_block.rbs +27 -0
- data/sig/ruby_raider/runtime/observer.rbs +46 -0
- data/sig/ruby_raider/runtime/role_finder.rbs +18 -0
- data/sig/ruby_raider/runtime/selectors.rbs +21 -0
- data/sig/ruby_raider/runtime/strict.rbs +35 -0
- data/sig/ruby_raider/runtime/wait.rbs +17 -0
- data/sig/ruby_raider/runtime.rbs +2 -0
- data/sig/scaffolding/project_detector.rbs +0 -4
- data/sig/scaffolding/scaffolding.rbs +0 -5
- data/sig/utilities/utilities.rbs +3 -1
- data/sig/vendor/selenium_webdriver.rbs +71 -0
- data/spec/commands/raider_commands_spec.rb +38 -3
- data/spec/commands/scaffolding_commands_spec.rb +27 -0
- data/spec/commands/utility_commands_spec.rb +53 -0
- data/spec/generators/fixtures/video_helper_stubs/selenium-webdriver.rb +11 -2
- data/spec/generators/gesture_helper_spec.rb +123 -0
- data/spec/generators/network_helper_spec.rb +634 -0
- data/spec/generators/screenshot_helper_spec.rb +776 -0
- data/spec/generators/template_renderer_spec.rb +0 -4
- data/spec/generators/trace_helper_spec.rb +1337 -0
- data/spec/generators/video_helper_spec.rb +0 -9
- data/spec/integration/commands/browser_update_after_creation_spec.rb +0 -8
- data/spec/integration/commands/scaffolding_commands_spec.rb +12 -70
- data/spec/integration/commands/utility_commands_spec.rb +19 -41
- data/spec/integration/content/azure_content_spec.rb +2 -6
- data/spec/integration/content/ci_content_spec.rb +1 -55
- data/spec/integration/content/common_content_spec.rb +1 -118
- data/spec/integration/content/config_content_spec.rb +52 -29
- data/spec/integration/content/gemfile_content_spec.rb +7 -72
- data/spec/integration/content/helper_content_spec.rb +158 -93
- data/spec/integration/content/page_content_spec.rb +85 -87
- data/spec/integration/content/readme_content_spec.rb +176 -71
- data/spec/integration/content/rspec_reporter_content_spec.rb +2 -2
- data/spec/integration/content/rubocop_content_spec.rb +1 -1
- data/spec/integration/content/syntax_validation_spec.rb +2 -2
- data/spec/integration/content/test_content_spec.rb +23 -147
- data/spec/integration/end_to_end_features_spec.rb +1 -43
- data/spec/integration/end_to_end_spec.rb +648 -292
- data/spec/integration/generators/automation_generator_spec.rb +3 -37
- data/spec/integration/generators/axe_addon_spec.rb +2 -35
- data/spec/integration/generators/azure_generator_spec.rb +1 -1
- data/spec/integration/generators/common_generator_spec.rb +1 -40
- data/spec/integration/generators/config_features_spec.rb +1 -24
- data/spec/integration/generators/github_generator_spec.rb +0 -12
- data/spec/integration/generators/helpers_generator_spec.rb +91 -71
- data/spec/integration/generators/invoke_generators_spec.rb +54 -45
- data/spec/integration/generators/rspec_generator_spec.rb +0 -6
- data/spec/integration/scaffolding_e2e_spec.rb +17 -179
- data/spec/integration/spec_helper.rb +4 -6
- data/spec/integration/trace_format_checker.rb +150 -0
- data/spec/integration/trace_page_server.rb +147 -0
- data/spec/menus/menu_generator_spec.rb +14 -39
- data/spec/runtime/actionability_spec.rb +207 -0
- data/spec/runtime/actionable_spec.rb +125 -0
- data/spec/runtime/browser/actionability_script_browser_spec.rb +150 -0
- data/spec/runtime/browser/actionable_browser_spec.rb +98 -0
- data/spec/runtime/browser/finders_browser_spec.rb +148 -0
- data/spec/runtime/browser/matchers_browser_spec.rb +67 -0
- data/spec/runtime/browser/retrying_block_browser_spec.rb +37 -0
- data/spec/runtime/browser/role_engine_browser_spec.rb +184 -0
- data/spec/runtime/browser/strict_browser_spec.rb +38 -0
- data/spec/runtime/by_role_spec.rb +52 -0
- data/spec/runtime/config_spec.rb +79 -0
- data/spec/runtime/context_spec.rb +73 -0
- data/spec/runtime/errors_spec.rb +89 -0
- data/spec/runtime/finders_spec.rb +165 -0
- data/spec/runtime/fixtures/actionability.html +70 -0
- data/spec/runtime/fixtures/locators.html +46 -0
- data/spec/runtime/fixtures/matchers.html +33 -0
- data/spec/runtime/fixtures/roles.html +162 -0
- data/spec/runtime/matchers/base_spec.rb +165 -0
- data/spec/runtime/matchers/element_spec.rb +277 -0
- data/spec/runtime/matchers/page_spec.rb +102 -0
- data/spec/runtime/matchers/presence_spec.rb +59 -0
- data/spec/runtime/matchers/retrying_block_spec.rb +165 -0
- data/spec/runtime/observer_spec.rb +341 -0
- data/spec/runtime/role_finder_spec.rb +156 -0
- data/spec/runtime/role_query_spec.rb +75 -0
- data/spec/runtime/selectors_spec.rb +135 -0
- data/spec/runtime/strict_spec.rb +257 -0
- data/spec/runtime/support/browser.rb +48 -0
- data/spec/runtime/support/fake_bridge.rb +117 -0
- data/spec/runtime/wait_spec.rb +71 -0
- data/spec/scaffolding/name_normalizer_spec.rb +3 -2
- data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -43
- data/spec/system/selenium_spec.rb +1 -5
- data/spec/system/support/system_test_helper.rb +2 -5
- data/spec/utilities/headless_config_spec.rb +0 -7
- data/spec/utilities/trace_command_spec.rb +66 -0
- data/spec/utilities/utilities_spec.rb +24 -0
- metadata +134 -44
- data/lib/generators/automation/templates/header.tt +0 -9
- data/lib/generators/cucumber/cucumber_generator.rb +0 -58
- data/lib/generators/cucumber/templates/accessibility_feature.tt +0 -5
- data/lib/generators/cucumber/templates/accessibility_steps.tt +0 -17
- data/lib/generators/cucumber/templates/cucumber.tt +0 -1
- data/lib/generators/cucumber/templates/env.tt +0 -7
- data/lib/generators/cucumber/templates/feature.tt +0 -21
- data/lib/generators/cucumber/templates/partials/appium_env.tt +0 -26
- data/lib/generators/cucumber/templates/partials/driver_world.tt +0 -18
- data/lib/generators/cucumber/templates/partials/mobile_steps.tt +0 -20
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -56
- data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -48
- data/lib/generators/cucumber/templates/partials/watir_world.tt +0 -4
- data/lib/generators/cucumber/templates/partials/web_steps.tt +0 -28
- data/lib/generators/cucumber/templates/steps.tt +0 -5
- data/lib/generators/cucumber/templates/user_factory.tt +0 -15
- data/lib/generators/cucumber/templates/world.tt +0 -7
- data/lib/generators/templates/helpers/browser_helper.tt +0 -31
- data/lib/generators/templates/helpers/raider_element.tt +0 -159
- data/lib/generators/templates/helpers/wait_helper.tt +0 -470
- data/lib/scaffolding/templates/feature.tt +0 -6
- data/lib/scaffolding/templates/steps.tt +0 -19
- data/sig/generators/cucumber/cucumber_generator.rbs +0 -12
- data/spec/fixtures/watir_master/cucumber_watir/Readme.md.snapshot +0 -175
- data/spec/fixtures/watir_master/cucumber_watir/features/step_definitions/login_steps.rb.snapshot +0 -24
- data/spec/fixtures/watir_master/cucumber_watir/page_objects/abstract/page.rb.snapshot +0 -37
- data/spec/fixtures/watir_master/cucumber_watir/page_objects/pages/login.rb.snapshot +0 -33
- data/spec/fixtures/watir_master/rspec_watir/Readme.md.snapshot +0 -174
- data/spec/fixtures/watir_master/rspec_watir/page_objects/abstract/page.rb.snapshot +0 -37
- data/spec/fixtures/watir_master/rspec_watir/page_objects/pages/login.rb.snapshot +0 -33
- data/spec/fixtures/watir_master/rspec_watir/spec/login_page_spec.rb.snapshot +0 -49
- data/spec/integration/content/cucumber_reporter_content_spec.rb +0 -110
- data/spec/integration/generators/cucumber_generator_spec.rb +0 -100
- data/spec/integration/helpers/wait_helper_mobile_spec.rb +0 -281
- data/spec/integration/helpers/wait_helper_spec.rb +0 -496
- data/spec/integration/helpers/wait_helper_support.rb +0 -183
- data/spec/system/watir_spec.rb +0 -38
|
@@ -42,53 +42,17 @@ describe 'Gemfile content' do
|
|
|
42
42
|
expect(gemfile).to include("gem 'rubocop-rspec'")
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
it 'does not include cucumber' do
|
|
46
|
-
expect(gemfile).not_to include("gem 'cucumber'")
|
|
47
|
-
end
|
|
48
|
-
|
|
49
45
|
it 'does not include minitest' do
|
|
50
46
|
expect(gemfile).not_to include("gem 'minitest'\n")
|
|
51
47
|
end
|
|
52
48
|
end
|
|
53
49
|
|
|
54
|
-
shared_examples 'contains cucumber gems' do |project_name|
|
|
55
|
-
subject(:gemfile) { read_generated(project_name, 'Gemfile') }
|
|
56
|
-
|
|
57
|
-
it 'includes cucumber' do
|
|
58
|
-
expect(gemfile).to include("gem 'cucumber'")
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it 'does not include allure-cucumber' do
|
|
62
|
-
expect(gemfile).not_to include('allure')
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'includes rspec as cucumber dependency' do
|
|
66
|
-
expect(gemfile).to include("gem 'rspec'")
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
50
|
shared_examples 'contains selenium gems' do |project_name|
|
|
71
51
|
subject(:gemfile) { read_generated(project_name, 'Gemfile') }
|
|
72
52
|
|
|
73
53
|
it 'includes selenium-webdriver' do
|
|
74
54
|
expect(gemfile).to include("gem 'selenium-webdriver'")
|
|
75
55
|
end
|
|
76
|
-
|
|
77
|
-
it 'does not include watir' do
|
|
78
|
-
expect(gemfile).not_to include("gem 'watir'")
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
shared_examples 'contains watir gems' do |project_name|
|
|
83
|
-
subject(:gemfile) { read_generated(project_name, 'Gemfile') }
|
|
84
|
-
|
|
85
|
-
it 'includes watir' do
|
|
86
|
-
expect(gemfile).to include("gem 'watir'")
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'does not include selenium-webdriver' do
|
|
90
|
-
expect(gemfile).not_to include("gem 'selenium-webdriver'")
|
|
91
|
-
end
|
|
92
56
|
end
|
|
93
57
|
|
|
94
58
|
context 'with rspec and selenium' do
|
|
@@ -98,27 +62,6 @@ describe 'Gemfile content' do
|
|
|
98
62
|
include_examples 'contains selenium gems', name
|
|
99
63
|
end
|
|
100
64
|
|
|
101
|
-
context 'with rspec and watir' do
|
|
102
|
-
name = "#{FrameworkIndex::RSPEC}_#{AutomationIndex::WATIR}"
|
|
103
|
-
include_examples 'contains common gems', name
|
|
104
|
-
include_examples 'contains rspec gems', name
|
|
105
|
-
include_examples 'contains watir gems', name
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context 'with cucumber and selenium' do
|
|
109
|
-
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}"
|
|
110
|
-
include_examples 'contains common gems', name
|
|
111
|
-
include_examples 'contains cucumber gems', name
|
|
112
|
-
include_examples 'contains selenium gems', name
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
context 'with cucumber and watir' do
|
|
116
|
-
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}"
|
|
117
|
-
include_examples 'contains common gems', name
|
|
118
|
-
include_examples 'contains cucumber gems', name
|
|
119
|
-
include_examples 'contains watir gems', name
|
|
120
|
-
end
|
|
121
|
-
|
|
122
65
|
describe 'raider_reporter and ruby_raider pin' do
|
|
123
66
|
major_minor = File.read('lib/version').strip.split('.').first(2).join('.')
|
|
124
67
|
|
|
@@ -127,7 +70,11 @@ describe 'Gemfile content' do
|
|
|
127
70
|
let(:gemfile) { read_generated("#{FrameworkIndex::RSPEC}_#{automation}", 'Gemfile') }
|
|
128
71
|
|
|
129
72
|
it 'includes raider_reporter' do
|
|
130
|
-
expect(gemfile).to include("gem 'raider_reporter', '~> 0
|
|
73
|
+
expect(gemfile).to include("gem 'raider_reporter', '~> 1.0'")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "#{automation == 'selenium' ? 'includes' : 'leaves out'} chunky_png" do
|
|
77
|
+
expect(gemfile.include?("gem 'chunky_png'")).to eq(automation == 'selenium')
|
|
131
78
|
end
|
|
132
79
|
|
|
133
80
|
it 'has no allure gems' do
|
|
@@ -137,21 +84,9 @@ describe 'Gemfile content' do
|
|
|
137
84
|
it 'pins ruby_raider to the generator major.minor' do
|
|
138
85
|
expect(gemfile).to include("gem 'ruby_raider', '~> #{major_minor}'")
|
|
139
86
|
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
context "with cucumber and #{automation}" do
|
|
143
|
-
let(:gemfile) { read_generated("#{FrameworkIndex::CUCUMBER}_#{automation}", 'Gemfile') }
|
|
144
|
-
|
|
145
|
-
it 'includes raider_reporter' do
|
|
146
|
-
expect(gemfile).to include("gem 'raider_reporter', '~> 0.10'")
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it 'drops allure-cucumber' do
|
|
150
|
-
expect(gemfile).not_to include('allure')
|
|
151
|
-
end
|
|
152
87
|
|
|
153
|
-
it 'pins ruby_raider to the
|
|
154
|
-
expect(gemfile).to include("gem 'ruby_raider', '~>
|
|
88
|
+
it 'pins ruby_raider to the 4.0 release line' do
|
|
89
|
+
expect(gemfile).to include("gem 'ruby_raider', '~> 4.0'")
|
|
155
90
|
end
|
|
156
91
|
end
|
|
157
92
|
end
|
|
@@ -36,13 +36,42 @@ describe 'Helper file content' do
|
|
|
36
36
|
expect(helper).to include("require 'selenium-webdriver'")
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it '
|
|
40
|
-
|
|
39
|
+
it 'requires the runtime right after selenium-webdriver' do
|
|
40
|
+
lines = helper.lines.map(&:chomp)
|
|
41
|
+
expect(lines[lines.index("require 'selenium-webdriver'") + 1]).to eq("require 'ruby_raider/runtime'")
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
it 'does not reference Capybara' do
|
|
44
45
|
expect(helper).not_to include('Capybara')
|
|
45
46
|
end
|
|
47
|
+
|
|
48
|
+
it 'requires network_helper before trace_helper' do
|
|
49
|
+
expect(helper).to include("require_relative 'network_helper'")
|
|
50
|
+
expect(helper.index("require_relative 'network_helper'")).to be < helper.index("require_relative 'trace_helper'")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'requires screenshot_helper next to network_helper' do
|
|
54
|
+
expect(helper).to include("require_relative 'screenshot_helper'")
|
|
55
|
+
expect(helper.index("require_relative 'screenshot_helper'")).to be > helper.index("require_relative 'network_helper'")
|
|
56
|
+
expect(helper.index("require_relative 'screenshot_helper'")).to be < helper.index("require_relative 'trace_helper'")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'requires trace_helper' do
|
|
60
|
+
expect(helper).to include("require_relative 'trace_helper'")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'sets web_socket_url only for chrome, edge and firefox and not with TRACE=off' do
|
|
64
|
+
expect(helper).to include('bidi = (defined?(TraceHelper) && TraceHelper.bidi?(load_browser)) ||',
|
|
65
|
+
'(defined?(NetworkHelper) && NetworkHelper.bidi?(load_browser))')
|
|
66
|
+
expect(helper).to include('options.web_socket_url = true if bidi')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'fans the video and trace listeners out through one listener, each guarded by defined?' do
|
|
70
|
+
expect(helper).to include('class FanOutListener < Selenium::WebDriver::Support::AbstractEventListener',
|
|
71
|
+
'listener = FanOutListener.for(listeners)',
|
|
72
|
+
'listeners << VideoHelper.listener if defined?(VideoHelper)',
|
|
73
|
+
'listeners << TraceHelper.listener if defined?(TraceHelper)')
|
|
74
|
+
end
|
|
46
75
|
end
|
|
47
76
|
|
|
48
77
|
# --- Browser helper ---
|
|
@@ -62,18 +91,10 @@ describe 'Helper file content' do
|
|
|
62
91
|
expect(helper).to match(/module BrowserHelper/)
|
|
63
92
|
end
|
|
64
93
|
|
|
65
|
-
it 'requires watir' do
|
|
66
|
-
expect(helper).to include("require 'watir'")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
94
|
it 'defines browser method' do
|
|
70
95
|
expect(helper).to match(/def browser/)
|
|
71
96
|
end
|
|
72
97
|
|
|
73
|
-
it 'creates Watir::Browser' do
|
|
74
|
-
expect(helper).to include('Watir::Browser.new')
|
|
75
|
-
end
|
|
76
|
-
|
|
77
98
|
it 'does not require selenium-webdriver' do
|
|
78
99
|
expect(helper).not_to include("require 'selenium-webdriver'")
|
|
79
100
|
end
|
|
@@ -103,6 +124,11 @@ describe 'Helper file content' do
|
|
|
103
124
|
it 'configures RSpec' do
|
|
104
125
|
expect(helper).to include('RSpec.configure')
|
|
105
126
|
end
|
|
127
|
+
|
|
128
|
+
it 'requires the rspec runtime and includes the Raider matchers and helpers' do
|
|
129
|
+
expect(helper).to include("require 'ruby_raider/runtime/rspec'", 'config.include(Raider::Matchers)',
|
|
130
|
+
'config.include(Raider::Helpers)')
|
|
131
|
+
end
|
|
106
132
|
end
|
|
107
133
|
|
|
108
134
|
shared_examples 'raider reporter spec helper' do |project_name, screenshot_call|
|
|
@@ -122,7 +148,7 @@ describe 'Helper file content' do
|
|
|
122
148
|
|
|
123
149
|
it 'screenshots only on failure' do
|
|
124
150
|
lines = helper.lines
|
|
125
|
-
start = lines.index { |line| line.
|
|
151
|
+
start = lines.index { |line| line.match?(/if (example\.exception|failure)$/) }
|
|
126
152
|
expect(start).not_to be_nil
|
|
127
153
|
indent = lines[start][/\A */].size
|
|
128
154
|
body = lines[(start + 1)..].take_while { |line| line.strip.empty? || line[/\A */].size > indent }
|
|
@@ -158,7 +184,7 @@ describe 'Helper file content' do
|
|
|
158
184
|
end
|
|
159
185
|
|
|
160
186
|
it 'attaches "video" only when example.exception && VideoHelper.final_attempt?(example)' do
|
|
161
|
-
expect(after_hook).to match(/example\.exception\s*(\?|&&)\s*VideoHelper\.final_attempt\?\(example\)/)
|
|
187
|
+
expect(after_hook).to match(/(example\.exception|failure)\s*(\?|&&)\s*VideoHelper\.final_attempt\?\(example\)/)
|
|
162
188
|
expect(after_hook).to include("RaiderReporter.attach('video', video_path, type: #{video_type}) if video_path")
|
|
163
189
|
end
|
|
164
190
|
|
|
@@ -168,7 +194,7 @@ describe 'Helper file content' do
|
|
|
168
194
|
after_hook.index(/driver\.quit|browser\.quit/)]
|
|
169
195
|
expect(order).to all(be_an(Integer)).and eq(order.compact.sort)
|
|
170
196
|
expect(after_hook.scan(/driver\.quit|browser\.quit/).size).to eq(1)
|
|
171
|
-
expect(after_hook[order[2]..]).to match(/\n @video_recorder&\.cleanup\n (driver|browser)\.quit(_driver)?\n end\n/)
|
|
197
|
+
expect(after_hook[order[2]..]).to match(/\n (@trace_recorder&\.cleanup\n )?@video_recorder&\.cleanup\n (driver|browser)\.quit(_driver)?\n( raise mock_error if mock_error\n)? end\n/)
|
|
172
198
|
end
|
|
173
199
|
|
|
174
200
|
it 'keeps the screenshot attachment' do
|
|
@@ -176,35 +202,81 @@ describe 'Helper file content' do
|
|
|
176
202
|
end
|
|
177
203
|
end
|
|
178
204
|
|
|
179
|
-
shared_examples '
|
|
205
|
+
shared_examples 'trace spec helper wiring' do |project_name|
|
|
180
206
|
subject(:helper) { read_generated(project_name, 'helpers/spec_helper.rb') }
|
|
181
207
|
|
|
182
|
-
|
|
183
|
-
|
|
208
|
+
let(:before_hook) { helper[/config\.before\(:each\) do.*?^ end$/m] }
|
|
209
|
+
let(:after_hook) { helper[/config\.after\(:each\).*\z/m] }
|
|
210
|
+
|
|
211
|
+
it 'starts the trace recorder after the video recorder, each guarded by defined?(TraceHelper)' do
|
|
212
|
+
expect(before_hook).to include('@trace_recorder = TraceHelper.recorder_for(driver) if defined?(TraceHelper)', '@trace_recorder&.start')
|
|
213
|
+
expect(before_hook.index('@video_recorder.start')).to be < before_hook.index('@trace_recorder = TraceHelper')
|
|
184
214
|
end
|
|
185
215
|
|
|
186
|
-
it '
|
|
187
|
-
expect(
|
|
216
|
+
it 'keeps the trace for TRACE=on or a final-attempt failure, falling back to keeping failures without a video helper' do
|
|
217
|
+
expect(after_hook).to match(/TraceHelper\.keep_all\? \|\| \((example\.exception|failure) && \(defined\?\(VideoHelper\) \? VideoHelper\.final_attempt\?\(example\) : true\)\)/)
|
|
188
218
|
end
|
|
189
219
|
|
|
190
|
-
it '
|
|
191
|
-
expect(
|
|
220
|
+
it 'counts the attempt from the rspec-retry metadata and hands the recorder the test' do
|
|
221
|
+
expect(after_hook).to include('example.metadata[:retry_attempts].to_i + 1')
|
|
222
|
+
expect(after_hook).to match(/error: (example\.exception|failure) \}/)
|
|
223
|
+
expect(after_hook).to include('@trace_recorder&.stop(keep: keep_trace, test: trace_test)')
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it 'stops the trace before the video and the screenshot, then attaches it, then cleans up before quitting' do
|
|
227
|
+
order = [after_hook.index('@trace_recorder&.stop'), after_hook.index('@video_recorder&.stop'), after_hook.index('RaiderReporter.attach(\'screenshot\''),
|
|
228
|
+
after_hook.index("RaiderReporter.attach('trace', trace_path, type: :trace, attempt: attempt) if trace_path"),
|
|
229
|
+
after_hook.index("\n ensure\n"), after_hook.index('@trace_recorder&.cleanup'), after_hook.index('@video_recorder&.cleanup'),
|
|
230
|
+
after_hook.index('driver.quit')]
|
|
231
|
+
expect(order).to all(be_an(Integer)).and eq(order.compact.sort)
|
|
192
232
|
end
|
|
193
233
|
end
|
|
194
234
|
|
|
195
|
-
shared_examples '
|
|
235
|
+
shared_examples 'network mock after hook' do |project_name|
|
|
196
236
|
subject(:helper) { read_generated(project_name, 'helpers/spec_helper.rb') }
|
|
197
237
|
|
|
198
|
-
|
|
199
|
-
|
|
238
|
+
let(:after_hook) { helper[/config\.after\(:each\).*\z/m] }
|
|
239
|
+
|
|
240
|
+
it 'finishes the router first and counts a mock error as a failure' do
|
|
241
|
+
expect(after_hook).to include('mock_error = NetworkHelper.finish(driver) if defined?(NetworkHelper)', 'failure = example.exception || mock_error')
|
|
242
|
+
expect(after_hook.index('mock_error = NetworkHelper.finish')).to be < after_hook.index('TraceHelper.keep_all?')
|
|
243
|
+
expect(after_hook).not_to include('example.exception ?', 'error: example.exception')
|
|
200
244
|
end
|
|
201
245
|
|
|
202
|
-
it '
|
|
203
|
-
expect(
|
|
246
|
+
it 'raises the mock error after the driver has quit' do
|
|
247
|
+
expect(after_hook.index('raise mock_error if mock_error')).to be > after_hook.index('driver.quit')
|
|
204
248
|
end
|
|
205
249
|
|
|
206
|
-
it '
|
|
207
|
-
expect(helper).to
|
|
250
|
+
it 'is valid Ruby' do
|
|
251
|
+
expect(helper).to have_valid_ruby_syntax
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
shared_examples 'no network mock wiring' do |project_name|
|
|
256
|
+
it 'leaves spec_helper.rb without NetworkHelper' do
|
|
257
|
+
expect(read_generated(project_name, 'helpers/spec_helper.rb')).not_to include('NetworkHelper', 'mock_error')
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
shared_examples 'no trace wiring' do |project_name, file|
|
|
262
|
+
it "leaves #{file} without trace code" do
|
|
263
|
+
expect(read_generated(project_name, file)).not_to match(/trace/i)
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
shared_examples 'selenium spec helper' do |project_name|
|
|
268
|
+
subject(:helper) { read_generated(project_name, 'helpers/spec_helper.rb') }
|
|
269
|
+
|
|
270
|
+
it 'includes DriverHelper' do
|
|
271
|
+
expect(helper).to include('include(DriverHelper)')
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
it 'requires driver_helper' do
|
|
275
|
+
expect(helper).to include("require_relative 'driver_helper'")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it 'maximizes window via driver' do
|
|
279
|
+
expect(helper).to include('driver.manage.window.maximize')
|
|
208
280
|
end
|
|
209
281
|
end
|
|
210
282
|
|
|
@@ -298,13 +370,6 @@ describe 'Helper file content' do
|
|
|
298
370
|
it_behaves_like 'video listener wiring', name, 'driver_helper.rb'
|
|
299
371
|
end
|
|
300
372
|
|
|
301
|
-
context 'with cucumber and watir video' do
|
|
302
|
-
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}"
|
|
303
|
-
it_behaves_like 'valid video helper', name
|
|
304
|
-
it_behaves_like 'web video helper', name
|
|
305
|
-
it_behaves_like 'video listener wiring', name, 'browser_helper.rb'
|
|
306
|
-
end
|
|
307
|
-
|
|
308
373
|
context 'with rspec and ios video' do
|
|
309
374
|
name = "#{FrameworkIndex::RSPEC}_#{AutomationIndex::IOS}"
|
|
310
375
|
it_behaves_like 'valid video helper', name
|
|
@@ -313,6 +378,10 @@ describe 'Helper file content' do
|
|
|
313
378
|
it 'does not wire a listener into the appium driver helper' do
|
|
314
379
|
expect(read_generated(name, 'helpers/driver_helper.rb')).not_to include('listener')
|
|
315
380
|
end
|
|
381
|
+
|
|
382
|
+
it 'does not wire tracing or BiDi into the appium driver helper' do
|
|
383
|
+
expect(read_generated(name, 'helpers/driver_helper.rb')).not_to include('TraceHelper', 'web_socket_url')
|
|
384
|
+
end
|
|
316
385
|
end
|
|
317
386
|
|
|
318
387
|
# --- RSpec + automation contexts ---
|
|
@@ -325,50 +394,29 @@ describe 'Helper file content' do
|
|
|
325
394
|
it_behaves_like 'selenium spec helper', name
|
|
326
395
|
end
|
|
327
396
|
|
|
328
|
-
context 'with rspec and watir' do
|
|
329
|
-
name = "#{FrameworkIndex::RSPEC}_#{AutomationIndex::WATIR}"
|
|
330
|
-
it_behaves_like 'valid browser helper', name
|
|
331
|
-
it_behaves_like 'valid spec helper', name
|
|
332
|
-
it_behaves_like 'watir spec helper', name
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
# --- Cucumber + automation contexts (no spec_helper/test_helper) ---
|
|
336
|
-
|
|
337
|
-
context 'with cucumber and selenium' do
|
|
338
|
-
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::SELENIUM}"
|
|
339
|
-
it_behaves_like 'valid driver helper', name
|
|
340
|
-
it_behaves_like 'selenium driver helper', name
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
context 'with cucumber and watir' do
|
|
344
|
-
name = "#{FrameworkIndex::CUCUMBER}_#{AutomationIndex::WATIR}"
|
|
345
|
-
it_behaves_like 'valid browser helper', name
|
|
346
|
-
end
|
|
347
|
-
|
|
348
397
|
# --- Raider reporter wiring (every rspec automation) ---
|
|
349
398
|
|
|
350
399
|
AUTOMATION_TYPES.each do |automation|
|
|
351
400
|
context "with rspec and #{automation} raider reporter wiring" do
|
|
352
401
|
name = "#{FrameworkIndex::RSPEC}_#{automation}"
|
|
353
402
|
screenshot_call = {
|
|
354
|
-
'selenium' => 'driver.save_screenshot(screenshot_path)'
|
|
355
|
-
'watir' => 'browser.screenshot.save(screenshot_path)'
|
|
403
|
+
'selenium' => 'driver.save_screenshot(screenshot_path)'
|
|
356
404
|
}.fetch(automation, 'driver.screenshot(screenshot_path)')
|
|
357
405
|
it_behaves_like 'raider reporter spec helper', name, screenshot_call
|
|
358
|
-
it_behaves_like 'video spec helper wiring', name, automation == '
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
406
|
+
it_behaves_like 'video spec helper wiring', name, 'driver', automation == 'selenium' ? ':webm' : ':mp4'
|
|
407
|
+
if automation == 'selenium'
|
|
408
|
+
it_behaves_like 'trace spec helper wiring', name
|
|
409
|
+
it_behaves_like 'network mock after hook', name
|
|
410
|
+
else
|
|
411
|
+
it_behaves_like 'no trace wiring', name, 'helpers/spec_helper.rb'
|
|
412
|
+
it_behaves_like 'no network mock wiring', name
|
|
365
413
|
end
|
|
366
414
|
end
|
|
367
415
|
end
|
|
368
416
|
|
|
369
417
|
# --- Opt-in login reuse ---
|
|
370
418
|
|
|
371
|
-
{ 'selenium' => 'driver'
|
|
419
|
+
{ 'selenium' => 'driver' }.each do |automation, target|
|
|
372
420
|
context "with rspec and #{automation} login reuse" do
|
|
373
421
|
subject(:helper) { read_generated("#{FrameworkIndex::RSPEC}_#{automation}", 'helpers/spec_helper.rb') }
|
|
374
422
|
|
|
@@ -379,7 +427,7 @@ describe 'Helper file content' do
|
|
|
379
427
|
it 'reuses the saved login for the driver, falling back to the real login' do
|
|
380
428
|
expect(helper).to include("SessionState.new(#{target}).reuse(")
|
|
381
429
|
expect(helper).to include("user = ModelFactory.for('users')['registered user']", ".login(user['username'], user['password'])")
|
|
382
|
-
expect(helper).to include("
|
|
430
|
+
expect(helper).to include("welcome_message.text == \"Welcome back \#{user['name']}\"")
|
|
383
431
|
end
|
|
384
432
|
|
|
385
433
|
it 'requires the models and pages the login needs' do
|
|
@@ -402,15 +450,26 @@ end
|
|
|
402
450
|
describe 'Auto-waiting helper wiring' do
|
|
403
451
|
%w[selenium ios android cross_platform].each do |automation|
|
|
404
452
|
context "with rspec and #{automation}" do
|
|
405
|
-
it '
|
|
453
|
+
it 'leaves the wait helper out of the spec helper' do
|
|
454
|
+
helper = read_generated("#{FrameworkIndex::RSPEC}_#{automation}", 'helpers/spec_helper.rb')
|
|
455
|
+
expect(helper).not_to include('wait_helper', 'WaitHelper')
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it "#{automation == 'selenium' ? 'includes' : 'leaves out'} NetworkHelper in the spec helper" do
|
|
406
459
|
helper = read_generated("#{FrameworkIndex::RSPEC}_#{automation}", 'helpers/spec_helper.rb')
|
|
407
|
-
expect(helper
|
|
460
|
+
expect(helper.include?('config.include(NetworkHelper)')).to eq(automation == 'selenium')
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
it "#{automation == 'selenium' ? 'includes' : 'leaves out'} ScreenshotHelper in the spec helper" do
|
|
464
|
+
helper = read_generated("#{FrameworkIndex::RSPEC}_#{automation}", 'helpers/spec_helper.rb')
|
|
465
|
+
expect(helper.include?('config.include(ScreenshotHelper)')).to eq(automation == 'selenium')
|
|
466
|
+
expect(helper.include?("require_relative 'screenshot_helper'")).to eq(automation == 'selenium')
|
|
408
467
|
end
|
|
409
468
|
end
|
|
410
469
|
end
|
|
411
470
|
|
|
412
471
|
%w[ios android cross_platform].each do |automation|
|
|
413
|
-
|
|
472
|
+
FRAMEWORKS.each do |framework|
|
|
414
473
|
it "does not pass a wait to appium_lib in #{framework} #{automation}" do
|
|
415
474
|
driver = read_generated("#{framework}_#{automation}", 'helpers/driver_helper.rb')
|
|
416
475
|
expect(driver).not_to match(/\bwait:/)
|
|
@@ -418,7 +477,7 @@ describe 'Auto-waiting helper wiring' do
|
|
|
418
477
|
end
|
|
419
478
|
end
|
|
420
479
|
|
|
421
|
-
|
|
480
|
+
FRAMEWORKS.each do |framework|
|
|
422
481
|
it "returns the new driver without a redundant assignment in #{framework} selenium" do
|
|
423
482
|
driver = read_generated("#{framework}_selenium", 'helpers/driver_helper.rb')
|
|
424
483
|
expect(driver).to include(" Selenium::WebDriver.for(browser.to_sym, **arguments)\n end")
|
|
@@ -429,14 +488,6 @@ describe 'Auto-waiting helper wiring' do
|
|
|
429
488
|
driver = read_generated("#{framework}_selenium", 'helpers/driver_helper.rb')
|
|
430
489
|
expect(driver).not_to include('implicit_wait')
|
|
431
490
|
end
|
|
432
|
-
|
|
433
|
-
it "keeps Watir untouched in #{framework} watir" do
|
|
434
|
-
project = "#{framework}_watir"
|
|
435
|
-
expect(File.exist?(File.join(project, 'helpers/wait_helper.rb'))).to be(false)
|
|
436
|
-
expect(read_generated(project, 'helpers/browser_helper.rb')).to include('Watir.default_timeout')
|
|
437
|
-
files = Dir.glob(File.join(project, '**/*.rb')).map { |f| File.read(f) }
|
|
438
|
-
expect(files.grep(/WaitHelper/)).to be_empty
|
|
439
|
-
end
|
|
440
491
|
end
|
|
441
492
|
|
|
442
493
|
describe 'without example tests' do
|
|
@@ -452,22 +503,6 @@ describe 'Auto-waiting helper wiring' do
|
|
|
452
503
|
expect(helper).to have_valid_ruby_syntax
|
|
453
504
|
end
|
|
454
505
|
end
|
|
455
|
-
|
|
456
|
-
context "with cucumber and #{automation}" do
|
|
457
|
-
let(:name) { ensure_project(framework: 'cucumber', automation:, examples: false) }
|
|
458
|
-
|
|
459
|
-
it 'names no example class or hook in the env and the World' do
|
|
460
|
-
%w[env.rb world.rb].each do |file|
|
|
461
|
-
expect(read_generated(name, "features/support/#{file}")).not_to match(/Login|Account|logged_in|factory/)
|
|
462
|
-
end
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
it 'has a valid env and World' do
|
|
466
|
-
%w[env.rb world.rb].each do |file|
|
|
467
|
-
expect(read_generated(name, "features/support/#{file}")).to have_valid_ruby_syntax
|
|
468
|
-
end
|
|
469
|
-
end
|
|
470
|
-
end
|
|
471
506
|
end
|
|
472
507
|
|
|
473
508
|
it 'keeps the session state require in the selenium rspec spec helper' do
|
|
@@ -477,3 +512,33 @@ describe 'Auto-waiting helper wiring' do
|
|
|
477
512
|
end
|
|
478
513
|
end
|
|
479
514
|
end
|
|
515
|
+
|
|
516
|
+
describe 'ScreenshotHelper reset between tests' do
|
|
517
|
+
it 'resets in the RSpec before(:each) of Selenium web projects only' do
|
|
518
|
+
selenium = read_generated('rspec_selenium', 'helpers/spec_helper.rb')
|
|
519
|
+
expect(selenium[/config\.before\(:each\) do.*?^ end$/m]).to include('ScreenshotHelper.reset')
|
|
520
|
+
%w[rspec_ios rspec_android].each do |project|
|
|
521
|
+
expect(read_generated(project, 'helpers/spec_helper.rb')).not_to include('ScreenshotHelper')
|
|
522
|
+
end
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
describe 'Runtime wiring in generated helpers' do
|
|
527
|
+
{ 'selenium' => "require 'selenium-webdriver'", 'ios' => "require 'appium_lib'",
|
|
528
|
+
'android' => "require 'appium_lib'", 'cross_platform' => "require 'appium_lib'" }.each do |automation, anchor|
|
|
529
|
+
context "with rspec and #{automation}" do
|
|
530
|
+
let(:name) { "#{FrameworkIndex::RSPEC}_#{automation}" }
|
|
531
|
+
|
|
532
|
+
it "requires the runtime right after #{anchor}" do
|
|
533
|
+
lines = read_generated(name, 'helpers/driver_helper.rb').lines.map(&:chomp)
|
|
534
|
+
expect(lines[lines.index(anchor) + 1]).to eq("require 'ruby_raider/runtime'")
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
it 'requires the rspec runtime and includes the matchers and helpers in spec_helper' do
|
|
538
|
+
expect(read_generated(name, 'helpers/spec_helper.rb'))
|
|
539
|
+
.to include("require 'ruby_raider/runtime/rspec'", 'config.include(Raider::Matchers)',
|
|
540
|
+
'config.include(Raider::Helpers)')
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
end
|
|
544
|
+
end
|