ruby_raider 3.13.0 → 4.0.1

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.
Files changed (239) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ffmpeg/build.sh +208 -0
  3. data/.github/ffmpeg/check.sh +72 -0
  4. data/.github/ffmpeg/frames.rb +34 -0
  5. data/.github/ffmpeg/probe.sh +17 -0
  6. data/.github/workflows/ffmpeg.yml +160 -0
  7. data/.github/workflows/runtime.yml +38 -0
  8. data/.github/workflows/system_tests.yml +1 -23
  9. data/.reek.yml +1 -0
  10. data/.rspec +1 -0
  11. data/Gemfile +2 -0
  12. data/README.md +172 -70
  13. data/RELEASE.md +29 -0
  14. data/bin/raider +5 -0
  15. data/lib/commands/scaffolding_commands.rb +2 -25
  16. data/lib/commands/utility_commands.rb +23 -3
  17. data/lib/generators/automation/automation_generator.rb +0 -5
  18. data/lib/generators/automation/templates/component.tt +1 -0
  19. data/lib/generators/automation/templates/home.tt +2 -2
  20. data/lib/generators/automation/templates/login.tt +6 -26
  21. data/lib/generators/automation/templates/page.tt +23 -18
  22. data/lib/generators/automation/templates/partials/home_page_selector.tt +1 -2
  23. data/lib/generators/automation/templates/partials/initialize_selector.tt +0 -8
  24. data/lib/generators/automation/templates/partials/pdp_page_selector.tt +1 -2
  25. data/lib/generators/automation/templates/partials/url_methods.tt +8 -2
  26. data/lib/generators/automation/templates/partials/visit_method.tt +0 -5
  27. data/lib/generators/automation/templates/pdp.tt +1 -9
  28. data/lib/generators/common_generator.rb +0 -2
  29. data/lib/generators/generator.rb +12 -19
  30. data/lib/generators/helper_generator.rb +21 -19
  31. data/lib/generators/infrastructure/templates/azure_pipelines.tt +1 -1
  32. data/lib/generators/infrastructure/templates/github.tt +2 -3
  33. data/lib/generators/infrastructure/templates/github_appium.tt +0 -8
  34. data/lib/generators/invoke_generators.rb +4 -23
  35. data/lib/generators/menu_generator.rb +1 -9
  36. data/lib/generators/rspec/templates/accessibility_spec.tt +1 -9
  37. data/lib/generators/rspec/templates/spec.tt +8 -24
  38. data/lib/generators/template_renderer/partial_cache.rb +3 -1
  39. data/lib/generators/template_renderer.rb +1 -1
  40. data/lib/generators/templates/common/gemfile.tt +3 -10
  41. data/lib/generators/templates/common/git_ignore.tt +0 -5
  42. data/lib/generators/templates/common/partials/mobile_config.tt +3 -1
  43. data/lib/generators/templates/common/partials/web_config.tt +10 -1
  44. data/lib/generators/templates/common/rakefile.tt +0 -15
  45. data/lib/generators/templates/common/read_me.tt +363 -257
  46. data/lib/generators/templates/common/rubocop.tt +0 -2
  47. data/lib/generators/templates/helpers/driver_helper.tt +8 -0
  48. data/lib/generators/templates/helpers/gesture_helper.tt +78 -0
  49. data/lib/generators/templates/helpers/network_helper.tt +521 -0
  50. data/lib/generators/templates/helpers/partials/quit_driver.tt +0 -2
  51. data/lib/generators/templates/helpers/partials/screenshot.tt +0 -2
  52. data/lib/generators/templates/helpers/partials/selenium_driver.tt +5 -2
  53. data/lib/generators/templates/helpers/screenshot_helper.tt +490 -0
  54. data/lib/generators/templates/helpers/spec_helper.tt +39 -29
  55. data/lib/generators/templates/helpers/trace_helper.tt +240 -95
  56. data/lib/generators/templates/helpers/video_helper.tt +4 -10
  57. data/lib/ruby_raider/ffmpeg.rb +38 -11
  58. data/lib/ruby_raider/runtime/actionability.rb +129 -0
  59. data/lib/ruby_raider/runtime/actionable.rb +49 -0
  60. data/lib/ruby_raider/runtime/by_role.rb +55 -0
  61. data/lib/ruby_raider/runtime/config.rb +79 -0
  62. data/lib/ruby_raider/runtime/context.rb +38 -0
  63. data/lib/ruby_raider/runtime/errors.rb +69 -0
  64. data/lib/ruby_raider/runtime/finders.rb +73 -0
  65. data/lib/ruby_raider/runtime/js/actionability.js +134 -0
  66. data/lib/ruby_raider/runtime/js/role_engine.js +315 -0
  67. data/lib/ruby_raider/runtime/locator_converter.rb +72 -0
  68. data/lib/ruby_raider/runtime/matchers/base.rb +222 -0
  69. data/lib/ruby_raider/runtime/matchers/element.rb +183 -0
  70. data/lib/ruby_raider/runtime/matchers/page.rb +71 -0
  71. data/lib/ruby_raider/runtime/matchers/presence.rb +41 -0
  72. data/lib/ruby_raider/runtime/matchers/retrying_block.rb +104 -0
  73. data/lib/ruby_raider/runtime/observer.rb +170 -0
  74. data/lib/ruby_raider/runtime/role_finder.rb +83 -0
  75. data/lib/ruby_raider/runtime/rspec.rb +78 -0
  76. data/lib/ruby_raider/runtime/selectors.rb +60 -0
  77. data/lib/ruby_raider/runtime/strict.rb +142 -0
  78. data/lib/ruby_raider/runtime/wait.rb +84 -0
  79. data/lib/ruby_raider/runtime.rb +20 -0
  80. data/lib/scaffolding/name_normalizer.rb +1 -1
  81. data/lib/scaffolding/project_detector.rb +2 -28
  82. data/lib/scaffolding/scaffolding.rb +0 -20
  83. data/lib/scaffolding/templates/component.tt +0 -14
  84. data/lib/scaffolding/templates/page_object.tt +2 -14
  85. data/lib/scaffolding/templates/spec.tt +1 -9
  86. data/lib/utilities/utilities.rb +10 -8
  87. data/lib/version +1 -1
  88. data/ruby_raider.gemspec +2 -1
  89. data/sig/commands/scaffolding_commands.rbs +0 -2
  90. data/sig/commands/utility_commands.rbs +6 -0
  91. data/sig/generators/generator.rbs +0 -4
  92. data/sig/generators/helper_generator.rbs +0 -1
  93. data/sig/generators/menu_generator.rbs +0 -1
  94. data/sig/ruby_raider/ffmpeg.rbs +1 -0
  95. data/sig/ruby_raider/runtime/actionability.rbs +25 -0
  96. data/sig/ruby_raider/runtime/actionable.rbs +13 -0
  97. data/sig/ruby_raider/runtime/by_role.rbs +15 -0
  98. data/sig/ruby_raider/runtime/config.rbs +26 -0
  99. data/sig/ruby_raider/runtime/context.rbs +12 -0
  100. data/sig/ruby_raider/runtime/errors.rbs +36 -0
  101. data/sig/ruby_raider/runtime/finders.rbs +26 -0
  102. data/sig/ruby_raider/runtime/locator_converter.rbs +21 -0
  103. data/sig/ruby_raider/runtime/matchers/base.rbs +64 -0
  104. data/sig/ruby_raider/runtime/matchers/element.rbs +78 -0
  105. data/sig/ruby_raider/runtime/matchers/page.rbs +38 -0
  106. data/sig/ruby_raider/runtime/matchers/presence.rbs +21 -0
  107. data/sig/ruby_raider/runtime/matchers/retrying_block.rbs +27 -0
  108. data/sig/ruby_raider/runtime/observer.rbs +46 -0
  109. data/sig/ruby_raider/runtime/role_finder.rbs +18 -0
  110. data/sig/ruby_raider/runtime/selectors.rbs +21 -0
  111. data/sig/ruby_raider/runtime/strict.rbs +35 -0
  112. data/sig/ruby_raider/runtime/wait.rbs +17 -0
  113. data/sig/ruby_raider/runtime.rbs +2 -0
  114. data/sig/scaffolding/project_detector.rbs +0 -4
  115. data/sig/scaffolding/scaffolding.rbs +0 -5
  116. data/sig/utilities/utilities.rbs +2 -1
  117. data/sig/vendor/selenium_webdriver.rbs +71 -0
  118. data/spec/commands/raider_commands_spec.rb +38 -3
  119. data/spec/commands/scaffolding_commands_spec.rb +27 -0
  120. data/spec/commands/utility_commands_spec.rb +53 -0
  121. data/spec/generators/gesture_helper_spec.rb +123 -0
  122. data/spec/generators/network_helper_spec.rb +634 -0
  123. data/spec/generators/screenshot_helper_spec.rb +776 -0
  124. data/spec/generators/template_renderer_spec.rb +0 -4
  125. data/spec/generators/trace_helper_spec.rb +489 -97
  126. data/spec/generators/video_helper_spec.rb +21 -13
  127. data/spec/integration/commands/browser_update_after_creation_spec.rb +0 -8
  128. data/spec/integration/commands/scaffolding_commands_spec.rb +12 -70
  129. data/spec/integration/commands/utility_commands_spec.rb +19 -41
  130. data/spec/integration/content/azure_content_spec.rb +2 -6
  131. data/spec/integration/content/ci_content_spec.rb +1 -55
  132. data/spec/integration/content/common_content_spec.rb +1 -118
  133. data/spec/integration/content/config_content_spec.rb +34 -31
  134. data/spec/integration/content/gemfile_content_spec.rb +7 -72
  135. data/spec/integration/content/helper_content_spec.rb +105 -99
  136. data/spec/integration/content/page_content_spec.rb +85 -87
  137. data/spec/integration/content/readme_content_spec.rb +141 -77
  138. data/spec/integration/content/rspec_reporter_content_spec.rb +2 -2
  139. data/spec/integration/content/rubocop_content_spec.rb +1 -1
  140. data/spec/integration/content/syntax_validation_spec.rb +2 -2
  141. data/spec/integration/content/test_content_spec.rb +23 -147
  142. data/spec/integration/end_to_end_features_spec.rb +1 -43
  143. data/spec/integration/end_to_end_spec.rb +334 -329
  144. data/spec/integration/generators/automation_generator_spec.rb +3 -37
  145. data/spec/integration/generators/axe_addon_spec.rb +2 -35
  146. data/spec/integration/generators/azure_generator_spec.rb +1 -1
  147. data/spec/integration/generators/common_generator_spec.rb +1 -40
  148. data/spec/integration/generators/config_features_spec.rb +1 -24
  149. data/spec/integration/generators/github_generator_spec.rb +0 -12
  150. data/spec/integration/generators/helpers_generator_spec.rb +74 -80
  151. data/spec/integration/generators/invoke_generators_spec.rb +54 -45
  152. data/spec/integration/generators/rspec_generator_spec.rb +0 -6
  153. data/spec/integration/scaffolding_e2e_spec.rb +17 -179
  154. data/spec/integration/spec_helper.rb +4 -6
  155. data/spec/integration/trace_format_checker.rb +11 -2
  156. data/spec/integration/trace_page_server.rb +72 -5
  157. data/spec/menus/menu_generator_spec.rb +14 -39
  158. data/spec/runtime/actionability_spec.rb +207 -0
  159. data/spec/runtime/actionable_spec.rb +125 -0
  160. data/spec/runtime/browser/actionability_script_browser_spec.rb +150 -0
  161. data/spec/runtime/browser/actionable_browser_spec.rb +98 -0
  162. data/spec/runtime/browser/finders_browser_spec.rb +148 -0
  163. data/spec/runtime/browser/matchers_browser_spec.rb +67 -0
  164. data/spec/runtime/browser/retrying_block_browser_spec.rb +37 -0
  165. data/spec/runtime/browser/role_engine_browser_spec.rb +184 -0
  166. data/spec/runtime/browser/strict_browser_spec.rb +38 -0
  167. data/spec/runtime/by_role_spec.rb +52 -0
  168. data/spec/runtime/config_spec.rb +79 -0
  169. data/spec/runtime/context_spec.rb +73 -0
  170. data/spec/runtime/errors_spec.rb +89 -0
  171. data/spec/runtime/finders_spec.rb +165 -0
  172. data/spec/runtime/fixtures/actionability.html +70 -0
  173. data/spec/runtime/fixtures/locators.html +46 -0
  174. data/spec/runtime/fixtures/matchers.html +33 -0
  175. data/spec/runtime/fixtures/roles.html +162 -0
  176. data/spec/runtime/matchers/base_spec.rb +165 -0
  177. data/spec/runtime/matchers/element_spec.rb +277 -0
  178. data/spec/runtime/matchers/page_spec.rb +102 -0
  179. data/spec/runtime/matchers/presence_spec.rb +59 -0
  180. data/spec/runtime/matchers/retrying_block_spec.rb +165 -0
  181. data/spec/runtime/observer_spec.rb +341 -0
  182. data/spec/runtime/role_finder_spec.rb +156 -0
  183. data/spec/runtime/role_query_spec.rb +75 -0
  184. data/spec/runtime/selectors_spec.rb +135 -0
  185. data/spec/runtime/strict_spec.rb +257 -0
  186. data/spec/runtime/support/browser.rb +48 -0
  187. data/spec/runtime/support/fake_bridge.rb +117 -0
  188. data/spec/runtime/wait_spec.rb +71 -0
  189. data/spec/scaffolding/name_normalizer_spec.rb +3 -2
  190. data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -43
  191. data/spec/system/selenium_spec.rb +1 -5
  192. data/spec/system/support/system_test_helper.rb +2 -5
  193. data/spec/utilities/ffmpeg_spec.rb +80 -7
  194. data/spec/utilities/headless_config_spec.rb +0 -7
  195. data/spec/utilities/utilities_spec.rb +24 -0
  196. data/spec/utilities/video_command_spec.rb +13 -0
  197. metadata +118 -53
  198. data/docs/superpowers/plans/2026-10-25-failure-video-replay.md +0 -400
  199. data/docs/superpowers/plans/2026-10-26-parity-cleanup.md +0 -233
  200. data/docs/superpowers/plans/2026-10-28-failure-card.md +0 -295
  201. data/docs/superpowers/specs/2026-10-25-failure-video-replay-design.md +0 -214
  202. data/docs/superpowers/specs/2026-10-28-failure-card-design.md +0 -210
  203. data/lib/generators/automation/templates/header.tt +0 -9
  204. data/lib/generators/cucumber/cucumber_generator.rb +0 -58
  205. data/lib/generators/cucumber/templates/accessibility_feature.tt +0 -5
  206. data/lib/generators/cucumber/templates/accessibility_steps.tt +0 -17
  207. data/lib/generators/cucumber/templates/cucumber.tt +0 -1
  208. data/lib/generators/cucumber/templates/env.tt +0 -7
  209. data/lib/generators/cucumber/templates/feature.tt +0 -21
  210. data/lib/generators/cucumber/templates/partials/appium_env.tt +0 -26
  211. data/lib/generators/cucumber/templates/partials/driver_world.tt +0 -18
  212. data/lib/generators/cucumber/templates/partials/mobile_steps.tt +0 -20
  213. data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -120
  214. data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -48
  215. data/lib/generators/cucumber/templates/partials/watir_world.tt +0 -4
  216. data/lib/generators/cucumber/templates/partials/web_steps.tt +0 -28
  217. data/lib/generators/cucumber/templates/steps.tt +0 -5
  218. data/lib/generators/cucumber/templates/user_factory.tt +0 -15
  219. data/lib/generators/cucumber/templates/world.tt +0 -7
  220. data/lib/generators/templates/helpers/browser_helper.tt +0 -31
  221. data/lib/generators/templates/helpers/raider_element.tt +0 -159
  222. data/lib/generators/templates/helpers/wait_helper.tt +0 -611
  223. data/lib/scaffolding/templates/feature.tt +0 -6
  224. data/lib/scaffolding/templates/steps.tt +0 -19
  225. data/sig/generators/cucumber/cucumber_generator.rbs +0 -12
  226. data/spec/fixtures/watir_master/cucumber_watir/Readme.md.snapshot +0 -175
  227. data/spec/fixtures/watir_master/cucumber_watir/features/step_definitions/login_steps.rb.snapshot +0 -24
  228. data/spec/fixtures/watir_master/cucumber_watir/page_objects/abstract/page.rb.snapshot +0 -37
  229. data/spec/fixtures/watir_master/cucumber_watir/page_objects/pages/login.rb.snapshot +0 -33
  230. data/spec/fixtures/watir_master/rspec_watir/Readme.md.snapshot +0 -174
  231. data/spec/fixtures/watir_master/rspec_watir/page_objects/abstract/page.rb.snapshot +0 -37
  232. data/spec/fixtures/watir_master/rspec_watir/page_objects/pages/login.rb.snapshot +0 -33
  233. data/spec/fixtures/watir_master/rspec_watir/spec/login_page_spec.rb.snapshot +0 -49
  234. data/spec/integration/content/cucumber_reporter_content_spec.rb +0 -161
  235. data/spec/integration/generators/cucumber_generator_spec.rb +0 -100
  236. data/spec/integration/helpers/wait_helper_mobile_spec.rb +0 -281
  237. data/spec/integration/helpers/wait_helper_spec.rb +0 -679
  238. data/spec/integration/helpers/wait_helper_support.rb +0 -183
  239. data/spec/system/watir_spec.rb +0 -38
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rspec'
4
+ require_relative '../../lib/ruby_raider/runtime/wait'
5
+
6
+ RSpec.describe 'Raider::Wait' do
7
+ after { Raider.reset }
8
+
9
+ def clock
10
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
11
+ end
12
+
13
+ describe '.until' do
14
+ it 'returns the block value' do
15
+ expect(Raider::Wait.until(timeout: 1) { :ready }).to eq(:ready)
16
+ end
17
+
18
+ it 'polls until the block succeeds' do
19
+ calls = 0
20
+ result = Raider::Wait.until(timeout: 1, interval: 0) { (calls += 1) >= 3 && calls }
21
+ expect([result, calls]).to eq([3, 3])
22
+ end
23
+
24
+ it 'raises with the thrown reason on the deadline' do
25
+ expect { Raider::Wait.until(timeout: 0.05, interval: 0) { throw :not_ready, 'still moving' } }
26
+ .to raise_error(Raider::TimeoutError, 'still moving')
27
+ end
28
+
29
+ it 'raises a default reason when nothing was thrown' do
30
+ expect { Raider::Wait.until(timeout: 0.05, interval: 0) { false } }
31
+ .to raise_error(Raider::TimeoutError, 'condition not met')
32
+ end
33
+
34
+ it 'uses Raider.timeout when none is given' do
35
+ Raider.timeout = 0.05
36
+ expect { Raider::Wait.until(interval: 0) { nil } }.to raise_error(Raider::TimeoutError)
37
+ end
38
+
39
+ it 'restores the deadline afterwards' do
40
+ Raider::Wait.until(timeout: 1) { Raider::Wait.deadline }
41
+ expect(Raider::Wait.deadline).to be_nil
42
+ end
43
+ end
44
+
45
+ describe 'eventually' do
46
+ it 'is gone' do
47
+ expect(Raider.respond_to?(:eventually)).to be(false)
48
+ expect(Raider::Wait.respond_to?(:eventually)).to be(false)
49
+ end
50
+ end
51
+
52
+ describe '.immediately' do
53
+ it 'returns the block value and flags the block as immediate' do
54
+ expect(Raider::Wait.immediate?).to be(false)
55
+ expect(Raider::Wait.immediately { Raider::Wait.immediate? }).to be(true)
56
+ expect(Raider::Wait.immediate?).to be(false)
57
+ end
58
+
59
+ it 'stays immediate when an inner call leaves' do
60
+ Raider::Wait.immediately do
61
+ Raider::Wait.immediately { :inner }
62
+ expect(Raider::Wait.immediate?).to be(true)
63
+ end
64
+ end
65
+
66
+ it 'restores the flag when the block raises' do
67
+ expect { Raider::Wait.immediately { raise ArgumentError } }.to raise_error(ArgumentError)
68
+ expect(Raider::Wait.immediate?).to be(false)
69
+ end
70
+ end
71
+ end
@@ -12,8 +12,9 @@ RSpec.describe NameNormalizer do
12
12
  expect(described_class.normalize('login_spec')).to eq('login')
13
13
  end
14
14
 
15
- it 'strips _steps suffix' do
16
- expect(described_class.normalize('login_steps')).to eq('login')
15
+ it 'keeps a _steps or _feature ending' do
16
+ expect(described_class.normalize('login_steps')).to eq('login_steps')
17
+ expect(described_class.normalize('login_feature')).to eq('login_feature')
17
18
  end
18
19
 
19
20
  it 'strips _helper suffix' do
@@ -26,42 +26,15 @@ RSpec.describe ScaffoldProjectDetector do
26
26
  expect(described_class.detect_automation).to eq('selenium')
27
27
  end
28
28
 
29
- it 'detects rspec framework' do
30
- expect(described_class.detect_framework).to eq('rspec')
31
- end
32
-
33
29
  it 'reports selenium?' do
34
30
  expect(described_class.selenium?).to be true
35
31
  end
36
32
  end
37
33
 
38
- context 'with watir project' do
39
- before do
40
- File.write('Gemfile', "gem 'watir'\ngem 'rspec'\n")
41
- FileUtils.mkdir_p('spec')
42
- end
43
-
44
- it 'detects watir automation' do
45
- expect(described_class.detect_automation).to eq('watir')
46
- end
47
-
48
- it 'detects rspec framework' do
49
- expect(described_class.detect_framework).to eq('rspec')
50
- end
51
-
52
- it 'reports watir?' do
53
- expect(described_class.watir?).to be true
54
- end
55
- end
56
-
57
34
  context 'with no Gemfile' do
58
35
  it 'defaults to selenium' do
59
36
  expect(described_class.detect_automation).to eq('selenium')
60
37
  end
61
-
62
- it 'defaults to rspec' do
63
- expect(described_class.detect_framework).to eq('rspec')
64
- end
65
38
  end
66
39
 
67
40
  describe '.validate_project' do
@@ -84,16 +57,8 @@ RSpec.describe ScaffoldProjectDetector do
84
57
  end
85
58
  end
86
59
 
87
- describe '.wait_helper?' do
88
- it 'is true when helpers/wait_helper.rb exists' do
89
- FileUtils.mkdir_p('helpers')
90
- File.write('helpers/wait_helper.rb', "# frozen_string_literal: true\n")
91
- expect(described_class.wait_helper?).to be true
92
- end
93
-
94
- it 'is false when the file does not exist' do
95
- expect(described_class.wait_helper?).to be false
96
- end
60
+ it 'no longer detects a wait helper' do
61
+ expect(described_class).not_to respond_to(:wait_helper?)
97
62
  end
98
63
 
99
64
  describe '.config' do
@@ -120,12 +85,8 @@ RSpec.describe ScaffoldProjectDetector do
120
85
  FileUtils.mkdir_p('spec')
121
86
  end
122
87
 
123
- it 'returns full detection hash' do
124
- result = described_class.detect
125
- expect(result[:automation]).to eq('selenium')
126
- expect(result[:framework]).to eq('rspec')
127
- expect(result[:has_spec]).to be true
128
- expect(result[:has_features]).to be false
88
+ it 'returns the automation and whether there is a spec folder, and nothing else' do
89
+ expect(described_class.detect).to eq(automation: 'selenium', has_spec: true)
129
90
  end
130
91
  end
131
92
  end
@@ -3,7 +3,7 @@
3
3
  require_relative '../../lib/ruby_raider'
4
4
  require_relative 'support/system_test_helper'
5
5
 
6
- FRAMEWORKS = %w[cucumber rspec].freeze
6
+ FRAMEWORKS = %w[rspec].freeze
7
7
 
8
8
  describe 'Selenium based frameworks' do
9
9
  include SystemTestHelper
@@ -31,8 +31,4 @@ describe 'Selenium based frameworks' do
31
31
  context 'with rspec' do
32
32
  include_examples 'runs tests successfully', 'rspec'
33
33
  end
34
-
35
- context 'with cucumber' do
36
- include_examples 'runs tests successfully', 'cucumber'
37
- end
38
34
  end
@@ -3,11 +3,8 @@
3
3
  require 'open3'
4
4
 
5
5
  module SystemTestHelper
6
- def test_command_for(framework)
7
- case framework
8
- when 'cucumber' then 'bundle exec cucumber features --format pretty'
9
- else 'bundle exec rspec spec --format documentation'
10
- end
6
+ def test_command_for(_framework)
7
+ 'bundle exec rspec spec --format documentation'
11
8
  end
12
9
 
13
10
  def run_tests_with(framework, automation)
@@ -41,11 +41,51 @@ describe RubyRaider::Ffmpeg do
41
41
  expect(described_class.platform(host_os: 'linux-gnu', host_cpu: 'aarch64')).to be_nil
42
42
  end
43
43
 
44
- it 'ships a placeholder manifest with https urls and nil checksums for all four platforms' do
45
- assets = described_class::MANIFEST[:assets]
46
- expect(assets.keys).to contain_exactly('darwin-arm64', 'darwin-x64', 'linux-x64', 'windows-x64')
47
- expect(assets.values.map { |a| a[:url] }).to all(start_with('https://'))
48
- expect(assets.values.map { |a| a[:sha256] }).to all(be_nil)
44
+ it 'pins a SHA-256 and the ffmpeg-7.1 release url for each of the four platforms', :aggregate_failures do
45
+ expect(described_class::MANIFEST[:version]).to eq('7.1')
46
+ base = 'https://github.com/RaiderHQ/ruby_raider/releases/download/ffmpeg-7.1/ffmpeg-7.1-'
47
+ expect(described_class::MANIFEST[:assets].transform_values { |a| a[:url] }).to eq(
48
+ 'darwin-arm64' => "#{base}darwin-arm64", 'darwin-x64' => "#{base}darwin-x64",
49
+ 'linux-x64' => "#{base}linux-x64", 'windows-x64' => "#{base}windows-x64.exe"
50
+ )
51
+ shas = described_class::MANIFEST[:assets].values.map { |a| a[:sha256] }
52
+ expect(shas).to all(match(/\A\h{64}\z/))
53
+ expect(shas.uniq.size).to eq(4)
54
+ end
55
+
56
+ describe 'the pinned checksums' do
57
+ let(:real) { described_class::MANIFEST }
58
+
59
+ it 'is obtainable on every supported platform without an override' do
60
+ described_class::PLATFORMS.each do |p|
61
+ expect(described_class.obtainable?(env: {}, platform: p)).to be(true)
62
+ end
63
+ end
64
+
65
+ it 'discards a download whose bytes do not match the pinned checksum', :aggregate_failures do
66
+ described_class::PLATFORMS.each do |p|
67
+ result = described_class.ensure!(env:, manifest: real, fetch:, warn: warner, platform: p)
68
+ expect(result).to be_nil
69
+ end
70
+ expect(calls).to eq(real[:assets].values.map { |a| a[:url] })
71
+ expect(warnings).to all(include('checksum mismatch'))
72
+ expect(Dir.glob(File.join(cache, '**', '*'))).to be_empty
73
+ end
74
+
75
+ # FFMPEG_ARTIFACTS=<dir> holding ffmpeg-7.1-<platform>[.exe] (the build workflow's artifacts
76
+ # or the release assets) proves those exact bytes pass verification and get cached.
77
+ it 'accepts the built binaries', unless: ENV.fetch('FFMPEG_ARTIFACTS', '').empty? do
78
+ described_class::PLATFORMS.each do |p|
79
+ name = File.basename(real[:assets][p][:url])
80
+ source = File.join(ENV.fetch('FFMPEG_ARTIFACTS'), name)
81
+ copy = ->(_url, dest) { FileUtils.cp(source, dest) }
82
+ own = { 'RAIDER_CACHE_DIR' => File.join(cache, p) }
83
+ path = described_class.ensure!(env: own, manifest: real, fetch: copy, warn: warner, platform: p)
84
+ expect(path).to eq(described_class.cached_path(env: own, manifest: real, platform: p))
85
+ expect(File.executable?(path)).to be(true)
86
+ end
87
+ expect(warnings).to be_empty
88
+ end
49
89
  end
50
90
 
51
91
  it 'derives the cache dir from RAIDER_CACHE_DIR or the home cache', :aggregate_failures do
@@ -254,6 +294,39 @@ describe RubyRaider::Ffmpeg do
254
294
  expect(warnings).to eq(['cached ffmpeg failed checksum; video disabled'])
255
295
  end
256
296
 
297
+ describe 'download size cap' do
298
+ let(:dest) { File.join(cache, 'download.part') }
299
+ let(:deadline) { Process.clock_gettime(Process::CLOCK_MONOTONIC) + 60 }
300
+
301
+ def ok_response(length, chunks)
302
+ response = Net::HTTPOK.new('1.1', '200', 'OK')
303
+ response['content-length'] = length.to_s if length
304
+ allow(response).to receive(:read_body) { |&block| chunks.each(&block) }
305
+ response
306
+ end
307
+
308
+ it 'refuses a Content-Length over the cap before writing anything', :aggregate_failures do
309
+ response = ok_response(described_class::MAX_DOWNLOAD_BYTES + 1, ['x'])
310
+ expect { described_class.send(:handle_response, response, dest, deadline, 60) }
311
+ .to raise_error(IOError, /larger than/)
312
+ expect(File).not_to exist(dest)
313
+ end
314
+
315
+ it 'stops writing once the body passes the cap, whatever Content-Length said' do
316
+ stub_const("#{described_class}::MAX_DOWNLOAD_BYTES", 10)
317
+ response = ok_response(nil, ['x' * 6, 'x' * 6, 'x' * 6])
318
+ expect { described_class.send(:handle_response, response, dest, deadline, 60) }
319
+ .to raise_error(IOError, /larger than/)
320
+ expect(File.size(dest)).to be <= 10
321
+ end
322
+
323
+ it 'writes a body within the cap' do
324
+ response = ok_response(4, %w[ab cd])
325
+ expect(described_class.send(:handle_response, response, dest, deadline, 60)).to be_nil
326
+ expect(File.read(dest)).to eq('abcd')
327
+ end
328
+ end
329
+
257
330
  describe 'DEFAULT_WARN' do
258
331
  it 'writes to $stderr even when $VERBOSE is nil' do
259
332
  original = $VERBOSE
@@ -281,8 +354,8 @@ describe RubyRaider::Ffmpeg do
281
354
  expect(described_class.obtainable?(env: {}, manifest:, platform: 'linux-x64')).to be(true)
282
355
  end
283
356
 
284
- it 'is false with no override and a nil checksum (the placeholder manifest)' do
285
- expect(described_class.obtainable?(env: {}, platform: 'darwin-arm64')).to be(false)
357
+ it 'is false with no override and a nil checksum' do
358
+ expect(described_class.obtainable?(env: {}, manifest: unpublished, platform: 'darwin-arm64')).to be(false)
286
359
  end
287
360
 
288
361
  it 'is false for an unknown platform or a non-executable override' do
@@ -31,13 +31,6 @@ RSpec.describe 'Headless config support in driver templates' do
31
31
  end
32
32
  end
33
33
 
34
- describe 'browser helper template (watir)' do
35
- it 'checks config headless key' do
36
- content = File.read(File.expand_path('../../lib/generators/templates/helpers/browser_helper.tt', __dir__))
37
- expect(content).to include("config['headless']")
38
- end
39
- end
40
-
41
34
  describe 'headless via config.yml' do
42
35
  it 'config key is used when YAML has headless: true' do
43
36
  FileUtils.mkdir_p('config')
@@ -104,6 +104,30 @@ RSpec.describe Utilities do
104
104
  end
105
105
  end
106
106
 
107
+ describe '.strict=' do
108
+ it 'sets strict to false' do
109
+ described_class.strict = false
110
+ expect(YAML.load_file(config_path)['strict']).to be false
111
+ end
112
+
113
+ it 'sets strict to true' do
114
+ described_class.strict = true
115
+ expect(YAML.load_file(config_path)['strict']).to be true
116
+ end
117
+ end
118
+
119
+ describe '.actionability=' do
120
+ it 'sets actionability to true' do
121
+ described_class.actionability = true
122
+ expect(YAML.load_file(config_path)['actionability']).to be true
123
+ end
124
+
125
+ it 'sets actionability to false' do
126
+ described_class.actionability = false
127
+ expect(YAML.load_file(config_path)['actionability']).to be false
128
+ end
129
+ end
130
+
107
131
  describe '.viewport=' do
108
132
  it 'sets viewport dimensions' do
109
133
  described_class.viewport = '375x812'
@@ -44,12 +44,25 @@ RSpec.describe UtilityCommands do
44
44
 
45
45
  describe 'video install' do
46
46
  it 'exits 1 and explains when the build is not published yet' do
47
+ require 'ruby_raider/ffmpeg'
48
+ unpublished = { version: '7.1', assets: { RubyRaider::Ffmpeg.platform.to_s => { url: 'https://example.test/x', sha256: nil } } }
49
+ stub_const('RubyRaider::Ffmpeg::MANIFEST', unpublished)
47
50
  out, err, status = run_cli('video', 'install')
48
51
  expect(status).to eq(1)
49
52
  expect(err).to include('[video]', 'ffmpeg build not published yet')
50
53
  expect(out).to eq('')
51
54
  end
52
55
 
56
+ it 'exits 1 and installs nothing when the download does not match the pinned checksum', :aggregate_failures do
57
+ require 'ruby_raider/ffmpeg'
58
+ allow(RubyRaider::Ffmpeg).to receive(:http_get) { |_url, dest| File.write(dest, 'not ffmpeg') }
59
+ out, err, status = run_cli('video', 'install')
60
+ expect(status).to eq(1)
61
+ expect(err).to include('[video]', 'checksum mismatch')
62
+ expect(out).to eq('')
63
+ expect(Dir.glob(File.join(cache, '**', '*'))).to be_empty
64
+ end
65
+
53
66
  it 'prints the path and exits 0 when ensure! succeeds' do
54
67
  require 'ruby_raider/ffmpeg'
55
68
  allow(RubyRaider::Ffmpeg).to receive(:ensure!).and_return('/tmp/ffmpeg')