ruby_raider 3.0.1 → 3.1.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.
Files changed (189) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/e2e_tests.yml +0 -17
  3. data/.github/workflows/system_tests.yml +0 -22
  4. data/README.md +8 -62
  5. data/lib/commands/scaffolding_commands.rb +1 -192
  6. data/lib/commands/utility_commands.rb +0 -43
  7. data/lib/generators/automation/templates/login.tt +1 -9
  8. data/lib/generators/automation/templates/page.tt +1 -7
  9. data/lib/generators/automation/templates/partials/initialize_selector.tt +1 -3
  10. data/lib/generators/automation/templates/partials/visit_method.tt +2 -6
  11. data/lib/generators/common_generator.rb +0 -6
  12. data/lib/generators/cucumber/cucumber_generator.rb +0 -24
  13. data/lib/generators/cucumber/templates/accessibility_steps.tt +2 -6
  14. data/lib/generators/cucumber/templates/cucumber.tt +0 -7
  15. data/lib/generators/cucumber/templates/env.tt +1 -3
  16. data/lib/generators/cucumber/templates/partials/appium_env.tt +1 -6
  17. data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -5
  18. data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -5
  19. data/lib/generators/cucumber/templates/partials/web_steps.tt +4 -4
  20. data/lib/generators/cucumber/templates/world.tt +1 -3
  21. data/lib/generators/generator.rb +2 -46
  22. data/lib/generators/helper_generator.rb +4 -42
  23. data/lib/generators/infrastructure/templates/github.tt +2 -2
  24. data/lib/generators/infrastructure/templates/github_appium.tt +2 -6
  25. data/lib/generators/invoke_generators.rb +4 -25
  26. data/lib/generators/menu_generator.rb +10 -100
  27. data/lib/generators/rspec/rspec_generator.rb +0 -11
  28. data/lib/generators/rspec/templates/accessibility_spec.tt +2 -6
  29. data/lib/generators/rspec/templates/spec.tt +6 -8
  30. data/lib/generators/templates/common/gemfile.tt +0 -26
  31. data/lib/generators/templates/common/git_ignore.tt +0 -2
  32. data/lib/generators/templates/common/partials/mobile_config.tt +0 -4
  33. data/lib/generators/templates/common/partials/web_config.tt +0 -4
  34. data/lib/generators/templates/common/rakefile.tt +0 -9
  35. data/lib/generators/templates/common/read_me.tt +4 -10
  36. data/lib/generators/templates/helpers/allure_helper.tt +0 -10
  37. data/lib/generators/templates/helpers/partials/debug_diagnostics.tt +1 -3
  38. data/lib/generators/templates/helpers/partials/debug_start.tt +1 -3
  39. data/lib/generators/templates/helpers/partials/quit_driver.tt +1 -3
  40. data/lib/generators/templates/helpers/partials/screenshot.tt +1 -3
  41. data/lib/generators/templates/helpers/spec_helper.tt +2 -39
  42. data/lib/ruby_raider.rb +2 -50
  43. data/lib/scaffolding/project_detector.rb +2 -9
  44. data/lib/scaffolding/scaffolding.rb +0 -109
  45. data/lib/scaffolding/templates/component.tt +1 -4
  46. data/lib/scaffolding/templates/page_object.tt +0 -10
  47. data/lib/scaffolding/templates/spec.tt +2 -6
  48. data/lib/scaffolding/templates/steps.tt +0 -2
  49. data/lib/utilities/utilities.rb +23 -29
  50. data/lib/version +1 -1
  51. data/sig/commands/scaffolding_commands.rbs +0 -12
  52. data/sig/commands/utility_commands.rbs +0 -6
  53. data/sig/generators/cucumber/cucumber_generator.rbs +0 -4
  54. data/sig/generators/generator.rbs +0 -11
  55. data/sig/generators/helper_generator.rbs +1 -5
  56. data/sig/generators/invoke_generators.rbs +1 -2
  57. data/sig/generators/menu_generator.rbs +2 -6
  58. data/sig/generators/rspec/rspec_generator.rbs +0 -2
  59. data/sig/ruby_raider.rbs +1 -3
  60. data/sig/scaffolding/project_detector.rbs +0 -1
  61. data/sig/scaffolding/scaffolding.rbs +0 -23
  62. data/sig/utilities/utilities.rbs +0 -4
  63. data/spec/commands/raider_commands_spec.rb +0 -61
  64. data/spec/integration/commands/browser_update_after_creation_spec.rb +123 -0
  65. data/spec/integration/commands/scaffolding_commands_spec.rb +0 -20
  66. data/spec/integration/commands/utility_commands_spec.rb +5 -5
  67. data/spec/integration/content/ci_content_spec.rb +6 -61
  68. data/spec/integration/content/common_content_spec.rb +0 -64
  69. data/spec/integration/content/config_content_spec.rb +1 -51
  70. data/spec/integration/content/content_helper.rb +2 -2
  71. data/spec/integration/content/gemfile_content_spec.rb +0 -71
  72. data/spec/integration/content/helper_content_spec.rb +4 -240
  73. data/spec/integration/content/page_content_spec.rb +0 -89
  74. data/spec/integration/content/syntax_validation_spec.rb +2 -2
  75. data/spec/integration/content/test_content_spec.rb +0 -119
  76. data/spec/integration/end_to_end_features_spec.rb +13 -411
  77. data/spec/integration/end_to_end_spec.rb +0 -96
  78. data/spec/integration/generators/axe_addon_spec.rb +2 -52
  79. data/spec/integration/generators/common_generator_spec.rb +1 -13
  80. data/spec/integration/generators/config_features_spec.rb +3 -81
  81. data/spec/integration/generators/debug_helper_spec.rb +0 -20
  82. data/spec/integration/generators/github_generator_spec.rb +5 -15
  83. data/spec/integration/generators/helpers_generator_spec.rb +0 -37
  84. data/spec/integration/scaffolding_e2e_spec.rb +2 -237
  85. data/spec/integration/settings_helper.rb +1 -3
  86. data/spec/integration/spec_helper.rb +6 -11
  87. data/spec/menus/menu_generator_spec.rb +4 -107
  88. data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -26
  89. data/spec/scaffolding/scaffolding_features_spec.rb +0 -183
  90. data/spec/system/selenium_spec.rb +1 -4
  91. data/spec/system/support/system_test_helper.rb +0 -1
  92. data/spec/system/watir_spec.rb +1 -4
  93. data/spec/utilities/headless_config_spec.rb +0 -7
  94. metadata +3 -97
  95. data/lib/adopter/adopt_menu.rb +0 -146
  96. data/lib/adopter/converters/base_converter.rb +0 -84
  97. data/lib/adopter/converters/identity_converter.rb +0 -53
  98. data/lib/adopter/migration_plan.rb +0 -74
  99. data/lib/adopter/migrator.rb +0 -96
  100. data/lib/adopter/plan_builder.rb +0 -275
  101. data/lib/adopter/project_analyzer.rb +0 -252
  102. data/lib/adopter/project_detector.rb +0 -157
  103. data/lib/generators/cucumber/templates/partials/capybara_env.tt +0 -38
  104. data/lib/generators/cucumber/templates/partials/capybara_world.tt +0 -6
  105. data/lib/generators/cucumber/templates/performance_feature.tt +0 -5
  106. data/lib/generators/cucumber/templates/performance_steps.tt +0 -17
  107. data/lib/generators/cucumber/templates/visual_feature.tt +0 -5
  108. data/lib/generators/cucumber/templates/visual_steps.tt +0 -19
  109. data/lib/generators/infrastructure/gitlab_generator.rb +0 -11
  110. data/lib/generators/infrastructure/templates/gitlab.tt +0 -46
  111. data/lib/generators/minitest/minitest_generator.rb +0 -35
  112. data/lib/generators/minitest/templates/accessibility_test.tt +0 -26
  113. data/lib/generators/minitest/templates/performance_test.tt +0 -18
  114. data/lib/generators/minitest/templates/test.tt +0 -64
  115. data/lib/generators/minitest/templates/visual_test.tt +0 -23
  116. data/lib/generators/rspec/templates/performance_spec.tt +0 -18
  117. data/lib/generators/rspec/templates/visual_spec.tt +0 -20
  118. data/lib/generators/templates/helpers/capybara_helper.tt +0 -32
  119. data/lib/generators/templates/helpers/performance_helper.tt +0 -57
  120. data/lib/generators/templates/helpers/visual_helper.tt +0 -58
  121. data/lib/llm/client.rb +0 -79
  122. data/lib/llm/config.rb +0 -57
  123. data/lib/llm/prompts.rb +0 -84
  124. data/lib/llm/provider.rb +0 -27
  125. data/lib/llm/providers/anthropic_provider.rb +0 -43
  126. data/lib/llm/providers/ollama_provider.rb +0 -56
  127. data/lib/llm/providers/openai_provider.rb +0 -42
  128. data/lib/llm/response_parser.rb +0 -67
  129. data/lib/plugin/plugin.rb +0 -111
  130. data/lib/plugin/plugin_exposer.rb +0 -55
  131. data/lib/scaffolding/crud_generator.rb +0 -94
  132. data/lib/scaffolding/dry_run_presenter.rb +0 -16
  133. data/lib/scaffolding/page_introspector.rb +0 -45
  134. data/lib/scaffolding/scaffold_menu.rb +0 -103
  135. data/lib/scaffolding/templates/page_from_url.tt +0 -75
  136. data/lib/scaffolding/templates/spec_from_page.tt +0 -31
  137. data/lib/scaffolding/templates/spec_from_url.tt +0 -46
  138. data/lib/scaffolding/url_analyzer.rb +0 -179
  139. data/sig/adopter/adopt_menu.rbs +0 -25
  140. data/sig/adopter/converters/base_converter.rbs +0 -23
  141. data/sig/adopter/converters/identity_converter.rbs +0 -16
  142. data/sig/adopter/migration_plan.rbs +0 -34
  143. data/sig/adopter/migrator.rbs +0 -21
  144. data/sig/adopter/plan_builder.rbs +0 -38
  145. data/sig/adopter/project_analyzer.rbs +0 -39
  146. data/sig/adopter/project_detector.rbs +0 -26
  147. data/sig/generators/infrastructure/gitlab_generator.rbs +0 -4
  148. data/sig/generators/minitest/minitest_generator.rbs +0 -8
  149. data/sig/llm/client.rbs +0 -15
  150. data/sig/llm/config.rbs +0 -20
  151. data/sig/llm/prompts.rbs +0 -8
  152. data/sig/llm/provider.rbs +0 -12
  153. data/sig/llm/providers/anthropic_provider.rbs +0 -16
  154. data/sig/llm/providers/ollama_provider.rbs +0 -18
  155. data/sig/llm/providers/openai_provider.rbs +0 -16
  156. data/sig/llm/response_parser.rbs +0 -13
  157. data/sig/plugin/plugin.rbs +0 -24
  158. data/sig/plugin/plugin_exposer.rbs +0 -20
  159. data/sig/scaffolding/crud_generator.rbs +0 -16
  160. data/sig/scaffolding/dry_run_presenter.rbs +0 -4
  161. data/sig/scaffolding/page_introspector.rbs +0 -14
  162. data/sig/scaffolding/scaffold_menu.rbs +0 -18
  163. data/sig/scaffolding/url_analyzer.rbs +0 -28
  164. data/spec/adopter/adopt_menu_spec.rb +0 -176
  165. data/spec/adopter/converters/identity_converter_spec.rb +0 -145
  166. data/spec/adopter/migration_plan_spec.rb +0 -113
  167. data/spec/adopter/migrator_spec.rb +0 -277
  168. data/spec/adopter/plan_builder_spec.rb +0 -298
  169. data/spec/adopter/project_analyzer_spec.rb +0 -337
  170. data/spec/adopter/project_detector_spec.rb +0 -295
  171. data/spec/generators/generator_spec.rb +0 -23
  172. data/spec/integration/content/reporter_content_spec.rb +0 -236
  173. data/spec/integration/content/skip_flags_content_spec.rb +0 -206
  174. data/spec/integration/generators/gitlab_generator_spec.rb +0 -38
  175. data/spec/integration/generators/lighthouse_addon_spec.rb +0 -132
  176. data/spec/integration/generators/minitest_generator_spec.rb +0 -64
  177. data/spec/integration/generators/reporter_spec.rb +0 -159
  178. data/spec/integration/generators/skip_flags_spec.rb +0 -134
  179. data/spec/integration/generators/visual_addon_spec.rb +0 -148
  180. data/spec/llm/client_spec.rb +0 -79
  181. data/spec/llm/config_spec.rb +0 -92
  182. data/spec/llm/prompts_spec.rb +0 -49
  183. data/spec/llm/response_parser_spec.rb +0 -92
  184. data/spec/menus/adopter_adopt_menu_spec.rb +0 -97
  185. data/spec/scaffolding/page_introspector_spec.rb +0 -82
  186. data/spec/scaffolding/url_analyzer_spec.rb +0 -110
  187. data/spec/system/adopt_matrix_spec.rb +0 -537
  188. data/spec/system/adopt_spec.rb +0 -225
  189. data/spec/system/capybara_spec.rb +0 -42
@@ -1,113 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'rspec'
5
- require_relative '../../lib/adopter/migration_plan'
6
-
7
- RSpec.describe Adopter::MigrationPlan do
8
- let(:converted_page) do
9
- Adopter::ConvertedFile.new(
10
- output_path: 'my_project/page_objects/pages/login.rb',
11
- content: 'class Login < Page; end',
12
- source_file: 'pages/login_page.rb',
13
- conversion_notes: 'Converted from capybara to selenium'
14
- )
15
- end
16
-
17
- let(:plan) do
18
- described_class.new(
19
- source_path: '/source',
20
- output_path: '/output',
21
- target_automation: 'selenium',
22
- target_framework: 'rspec',
23
- ci_platform: 'github',
24
- skeleton_structure: { automation: 'selenium', framework: 'rspec', name: '/output' },
25
- converted_pages: [converted_page],
26
- converted_tests: [],
27
- gemfile_additions: %w[faker httparty],
28
- config_overrides: { browser: 'chrome', url: 'https://example.com' },
29
- warnings: ['Complex matcher needs review'],
30
- manual_actions: []
31
- )
32
- end
33
-
34
- describe '#to_h' do
35
- it 'serializes all fields' do # rubocop:disable RSpec/MultipleExpectations
36
- hash = plan.to_h
37
- expect(hash[:source_path]).to eq('/source')
38
- expect(hash[:output_path]).to eq('/output')
39
- expect(hash[:target_automation]).to eq('selenium')
40
- expect(hash[:target_framework]).to eq('rspec')
41
- expect(hash[:converted_pages].length).to eq(1)
42
- expect(hash[:gemfile_additions]).to eq(%w[faker httparty])
43
- expect(hash[:config_overrides]).to eq(browser: 'chrome', url: 'https://example.com')
44
- end
45
-
46
- it 'serializes converted files as hashes' do
47
- page_hash = plan.to_h[:converted_pages].first
48
- expect(page_hash[:output_path]).to eq('my_project/page_objects/pages/login.rb')
49
- expect(page_hash[:source_file]).to eq('pages/login_page.rb')
50
- end
51
- end
52
-
53
- describe '#to_json' do
54
- it 'produces valid JSON' do
55
- parsed = JSON.parse(plan.to_json)
56
- expect(parsed['source_path']).to eq('/source')
57
- expect(parsed['converted_pages'].length).to eq(1)
58
- end
59
- end
60
-
61
- describe '#summary' do
62
- it 'returns counts' do
63
- expect(plan.summary).to eq(
64
- pages: 1,
65
- tests: 0,
66
- features: 0,
67
- steps: 0,
68
- custom_gems: 2,
69
- warnings: 1,
70
- manual_actions: 0
71
- )
72
- end
73
- end
74
-
75
- describe 'defaults' do
76
- it 'initializes with empty arrays and hashes' do
77
- empty_plan = described_class.new
78
- expect(empty_plan.converted_pages).to eq([])
79
- expect(empty_plan.converted_tests).to eq([])
80
- expect(empty_plan.gemfile_additions).to eq([])
81
- expect(empty_plan.config_overrides).to eq({})
82
- expect(empty_plan.warnings).to eq([])
83
- end
84
- end
85
- end
86
-
87
- RSpec.describe Adopter::ConvertedFile do
88
- it 'stores file conversion data' do
89
- file = described_class.new(
90
- output_path: 'project/spec/login_spec.rb',
91
- content: 'describe "Login" do; end',
92
- source_file: 'spec/login_spec.rb',
93
- conversion_notes: 'Restructured'
94
- )
95
- expect(file.output_path).to eq('project/spec/login_spec.rb')
96
- expect(file.content).to eq('describe "Login" do; end')
97
- end
98
-
99
- it 'serializes to hash' do
100
- file = described_class.new(
101
- output_path: 'out.rb',
102
- content: 'code',
103
- source_file: 'in.rb',
104
- conversion_notes: 'notes'
105
- )
106
- expect(file.to_h).to eq(
107
- output_path: 'out.rb',
108
- content: 'code',
109
- source_file: 'in.rb',
110
- conversion_notes: 'notes'
111
- )
112
- end
113
- end
@@ -1,277 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- require 'rspec'
5
- require_relative '../../lib/adopter/migration_plan'
6
- require_relative '../../lib/adopter/migrator'
7
-
8
- RSpec.describe Adopter::Migrator do
9
- let(:output_dir) { 'tmp_migrator_test' }
10
-
11
- after { FileUtils.rm_rf(output_dir) }
12
-
13
- describe '#execute' do
14
- context 'with skeleton generation' do
15
- let(:plan) do
16
- Adopter::MigrationPlan.new(
17
- source_path: 'dummy_source',
18
- output_path: output_dir,
19
- target_automation: 'selenium',
20
- target_framework: 'rspec',
21
- ci_platform: 'github',
22
- skeleton_structure: {
23
- automation: 'selenium',
24
- framework: 'rspec',
25
- name: output_dir,
26
- ci_platform: 'github'
27
- }
28
- )
29
- end
30
-
31
- it 'generates a raider project skeleton' do
32
- described_class.new(plan).execute
33
-
34
- expect(File).to exist("#{output_dir}/Gemfile")
35
- expect(File).to exist("#{output_dir}/Rakefile")
36
- expect(File).to exist("#{output_dir}/page_objects/pages")
37
- expect(File).to exist("#{output_dir}/spec")
38
- end
39
- end
40
-
41
- context 'writing converted pages' do
42
- let(:plan) do
43
- Adopter::MigrationPlan.new(
44
- source_path: 'dummy_source',
45
- output_path: output_dir,
46
- target_automation: 'selenium',
47
- target_framework: 'rspec',
48
- skeleton_structure: {
49
- automation: 'selenium',
50
- framework: 'rspec',
51
- name: output_dir
52
- },
53
- converted_pages: [
54
- Adopter::ConvertedFile.new(
55
- output_path: "#{output_dir}/page_objects/pages/login.rb",
56
- content: "# frozen_string_literal: true\n\nclass LoginPage < Page\nend\n",
57
- source_file: 'pages/login_page.rb',
58
- conversion_notes: 'Restructured'
59
- )
60
- ]
61
- )
62
- end
63
-
64
- it 'writes converted page files over the skeleton' do
65
- results = described_class.new(plan).execute
66
-
67
- expect(results[:pages]).to eq(1)
68
- content = File.read("#{output_dir}/page_objects/pages/login.rb")
69
- expect(content).to include('class LoginPage < Page')
70
- end
71
- end
72
-
73
- context 'writing converted tests' do
74
- let(:plan) do
75
- Adopter::MigrationPlan.new(
76
- source_path: 'dummy_source',
77
- output_path: output_dir,
78
- target_automation: 'selenium',
79
- target_framework: 'rspec',
80
- skeleton_structure: {
81
- automation: 'selenium',
82
- framework: 'rspec',
83
- name: output_dir
84
- },
85
- converted_tests: [
86
- Adopter::ConvertedFile.new(
87
- output_path: "#{output_dir}/spec/login_spec.rb",
88
- content: "# frozen_string_literal: true\n\ndescribe 'Login' do\nend\n",
89
- source_file: 'spec/login_spec.rb',
90
- conversion_notes: 'Restructured'
91
- )
92
- ]
93
- )
94
- end
95
-
96
- it 'writes converted test files' do
97
- results = described_class.new(plan).execute
98
-
99
- expect(results[:tests]).to eq(1)
100
- content = File.read("#{output_dir}/spec/login_spec.rb")
101
- expect(content).to include("describe 'Login'")
102
- end
103
- end
104
-
105
- context 'writing cucumber features and steps' do
106
- let(:plan) do
107
- Adopter::MigrationPlan.new(
108
- source_path: 'dummy_source',
109
- output_path: output_dir,
110
- target_automation: 'selenium',
111
- target_framework: 'cucumber',
112
- skeleton_structure: {
113
- automation: 'selenium',
114
- framework: 'cucumber',
115
- name: output_dir
116
- },
117
- converted_features: [
118
- Adopter::ConvertedFile.new(
119
- output_path: "#{output_dir}/features/login.feature",
120
- content: "Feature: Login\n Scenario: Valid login\n",
121
- source_file: 'features/login.feature',
122
- conversion_notes: 'Copied as-is'
123
- )
124
- ],
125
- converted_steps: [
126
- Adopter::ConvertedFile.new(
127
- output_path: "#{output_dir}/features/step_definitions/login_steps.rb",
128
- content: "Given('I am on the login page') do\nend\n",
129
- source_file: 'features/step_definitions/login_steps.rb',
130
- conversion_notes: 'Updated page references'
131
- )
132
- ]
133
- )
134
- end
135
-
136
- it 'writes feature and step files' do
137
- results = described_class.new(plan).execute
138
-
139
- expect(results[:features]).to eq(1)
140
- expect(results[:steps]).to eq(1)
141
- expect(File).to exist("#{output_dir}/features/login.feature")
142
- expect(File).to exist("#{output_dir}/features/step_definitions/login_steps.rb")
143
- end
144
- end
145
-
146
- context 'merging custom gems into Gemfile' do
147
- let(:plan) do
148
- Adopter::MigrationPlan.new(
149
- source_path: 'dummy_source',
150
- output_path: output_dir,
151
- target_automation: 'selenium',
152
- target_framework: 'rspec',
153
- skeleton_structure: {
154
- automation: 'selenium',
155
- framework: 'rspec',
156
- name: output_dir
157
- },
158
- gemfile_additions: %w[faker httparty]
159
- )
160
- end
161
-
162
- it 'appends custom gems to the generated Gemfile' do
163
- described_class.new(plan).execute
164
-
165
- gemfile = File.read("#{output_dir}/Gemfile")
166
- expect(gemfile).to include("gem 'faker'")
167
- expect(gemfile).to include("gem 'httparty'")
168
- expect(gemfile).to include('# Gems from source project')
169
- end
170
-
171
- it 'does not duplicate gems already in the Gemfile' do
172
- described_class.new(plan).execute
173
-
174
- # Selenium Gemfile already has 'rspec' — adding it again should be skipped
175
- plan2 = Adopter::MigrationPlan.new(
176
- source_path: 'dummy_source',
177
- output_path: output_dir,
178
- target_automation: 'selenium',
179
- target_framework: 'rspec',
180
- skeleton_structure: {
181
- automation: 'selenium',
182
- framework: 'rspec',
183
- name: output_dir
184
- },
185
- gemfile_additions: %w[faker new_gem]
186
- )
187
- described_class.new(plan2).execute
188
-
189
- gemfile = File.read("#{output_dir}/Gemfile")
190
- expect(gemfile.scan("gem 'faker'").length).to eq(1)
191
- expect(gemfile).to include("gem 'new_gem'")
192
- end
193
- end
194
-
195
- context 'applying config overrides' do
196
- let(:plan) do
197
- Adopter::MigrationPlan.new(
198
- source_path: 'dummy_source',
199
- output_path: output_dir,
200
- target_automation: 'selenium',
201
- target_framework: 'rspec',
202
- skeleton_structure: {
203
- automation: 'selenium',
204
- framework: 'rspec',
205
- name: output_dir
206
- },
207
- config_overrides: { browser: 'firefox', url: 'https://example.com' }
208
- )
209
- end
210
-
211
- it 'updates config.yml with overridden values' do
212
- described_class.new(plan).execute
213
-
214
- config = YAML.safe_load(File.read("#{output_dir}/config/config.yml"), permitted_classes: [Symbol])
215
- expect(config['browser']).to eq('firefox')
216
- expect(config['url']).to eq('https://example.com')
217
- end
218
- end
219
-
220
- context 'error handling' do
221
- let(:plan) do
222
- Adopter::MigrationPlan.new(
223
- source_path: 'dummy_source',
224
- output_path: output_dir,
225
- target_automation: 'selenium',
226
- target_framework: 'rspec',
227
- skeleton_structure: {
228
- automation: 'selenium',
229
- framework: 'rspec',
230
- name: output_dir
231
- },
232
- converted_pages: [
233
- Adopter::ConvertedFile.new(
234
- output_path: '/dev/null/impossible/path/file.rb',
235
- content: 'content',
236
- source_file: 'pages/bad.rb',
237
- conversion_notes: 'Will fail'
238
- )
239
- ]
240
- )
241
- end
242
-
243
- it 'captures write errors without stopping execution' do
244
- results = described_class.new(plan).execute
245
-
246
- expect(results[:errors]).not_to be_empty
247
- expect(results[:errors].first).to include('Failed to write')
248
- end
249
- end
250
-
251
- context 'results tracking' do
252
- let(:plan) do
253
- Adopter::MigrationPlan.new(
254
- source_path: 'dummy_source',
255
- output_path: output_dir,
256
- target_automation: 'selenium',
257
- target_framework: 'rspec',
258
- skeleton_structure: {
259
- automation: 'selenium',
260
- framework: 'rspec',
261
- name: output_dir
262
- }
263
- )
264
- end
265
-
266
- it 'returns zero counts when no files to convert' do
267
- results = described_class.new(plan).execute
268
-
269
- expect(results[:pages]).to eq(0)
270
- expect(results[:tests]).to eq(0)
271
- expect(results[:features]).to eq(0)
272
- expect(results[:steps]).to eq(0)
273
- expect(results[:errors]).to be_empty
274
- end
275
- end
276
- end
277
- end
@@ -1,298 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fileutils'
4
- require 'rspec'
5
- require_relative '../../lib/adopter/project_analyzer'
6
- require_relative '../../lib/adopter/plan_builder'
7
-
8
- RSpec.describe Adopter::PlanBuilder do
9
- let(:project_dir) { 'tmp_plan_builder_project' }
10
-
11
- before { FileUtils.mkdir_p(project_dir) }
12
-
13
- after { FileUtils.rm_rf(project_dir) }
14
-
15
- describe '#build' do
16
- context 'with a selenium + rspec project converting to same' do
17
- let(:params) do
18
- {
19
- source_path: project_dir,
20
- output_path: 'my_raider_project',
21
- target_automation: 'selenium',
22
- target_framework: 'rspec',
23
- ci_platform: 'github'
24
- }
25
- end
26
-
27
- before do
28
- File.write("#{project_dir}/Gemfile", <<~GEMFILE)
29
- gem 'rspec'
30
- gem 'selenium-webdriver'
31
- gem 'faker'
32
- GEMFILE
33
- FileUtils.mkdir_p("#{project_dir}/pages")
34
- FileUtils.mkdir_p("#{project_dir}/spec")
35
-
36
- File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
37
- class LoginPage < BasePage
38
- def login(user, pass)
39
- driver.find_element(id: 'user').send_keys user
40
- end
41
- end
42
- RUBY
43
-
44
- File.write("#{project_dir}/spec/login_spec.rb", <<~RUBY)
45
- describe 'Login' do
46
- it 'can log in' do
47
- expect(result).to eq 'ok'
48
- end
49
- end
50
- RUBY
51
- end
52
-
53
- it 'builds a valid migration plan' do
54
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
55
- plan = described_class.new(analysis, params).build
56
-
57
- expect(plan).to be_a(Adopter::MigrationPlan)
58
- expect(plan.source_path).to eq(project_dir)
59
- expect(plan.output_path).to eq('my_raider_project')
60
- expect(plan.target_automation).to eq('selenium')
61
- expect(plan.target_framework).to eq('rspec')
62
- end
63
-
64
- it 'builds correct skeleton structure' do
65
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
66
- plan = described_class.new(analysis, params).build
67
-
68
- expect(plan.skeleton_structure).to eq(
69
- automation: 'selenium',
70
- framework: 'rspec',
71
- name: 'my_raider_project',
72
- ci_platform: 'github'
73
- )
74
- end
75
-
76
- it 'converts pages with raider paths' do
77
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
78
- plan = described_class.new(analysis, params).build
79
-
80
- expect(plan.converted_pages.length).to eq(1)
81
- page = plan.converted_pages.first
82
- expect(page.output_path).to eq('my_raider_project/page_objects/pages/login.rb')
83
- expect(page.source_file).to eq('pages/login_page.rb')
84
- end
85
-
86
- it 'converts tests with raider paths' do
87
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
88
- plan = described_class.new(analysis, params).build
89
-
90
- expect(plan.converted_tests.length).to eq(1)
91
- test = plan.converted_tests.first
92
- expect(test.output_path).to eq('my_raider_project/spec/login_spec.rb')
93
- end
94
-
95
- it 'identifies custom gems' do
96
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
97
- plan = described_class.new(analysis, params).build
98
-
99
- expect(plan.gemfile_additions).to eq(['faker'])
100
- end
101
-
102
- it 'adds frozen_string_literal when missing' do
103
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
104
- plan = described_class.new(analysis, params).build
105
-
106
- page_content = plan.converted_pages.first.content
107
- expect(page_content).to include('frozen_string_literal: true')
108
- end
109
- end
110
-
111
- context 'converting to minitest output paths' do
112
- let(:params) do
113
- {
114
- source_path: project_dir,
115
- output_path: 'output',
116
- target_automation: 'selenium',
117
- target_framework: 'minitest'
118
- }
119
- end
120
-
121
- before do
122
- File.write("#{project_dir}/Gemfile", "gem 'rspec'\ngem 'selenium-webdriver'\n")
123
- FileUtils.mkdir_p("#{project_dir}/spec")
124
-
125
- File.write("#{project_dir}/spec/login_spec.rb", <<~RUBY)
126
- describe 'Login' do
127
- it 'works' do
128
- expect(true).to be true
129
- end
130
- end
131
- RUBY
132
- end
133
-
134
- it 'generates minitest-style output paths' do
135
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
136
- plan = described_class.new(analysis, params).build
137
-
138
- test = plan.converted_tests.first
139
- expect(test.output_path).to eq('output/test/test_login.rb')
140
- end
141
- end
142
-
143
- context 'converting to cucumber' do
144
- let(:params) do
145
- {
146
- source_path: project_dir,
147
- output_path: 'output',
148
- target_automation: 'selenium',
149
- target_framework: 'cucumber'
150
- }
151
- end
152
-
153
- before do
154
- File.write("#{project_dir}/Gemfile", "gem 'cucumber'\ngem 'selenium-webdriver'\n")
155
- FileUtils.mkdir_p("#{project_dir}/features/step_definitions")
156
-
157
- File.write("#{project_dir}/features/login.feature", <<~GHERKIN)
158
- Feature: Login
159
- Scenario: Valid login
160
- Given I am on the login page
161
- GHERKIN
162
-
163
- File.write("#{project_dir}/features/step_definitions/login_steps.rb", <<~RUBY)
164
- Given('I am on the login page') do
165
- @page = LoginPage.new(driver)
166
- end
167
- RUBY
168
- end
169
-
170
- it 'plans feature file copies' do
171
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
172
- plan = described_class.new(analysis, params).build
173
-
174
- expect(plan.converted_features.length).to eq(1)
175
- expect(plan.converted_features.first.output_path).to eq('output/features/login.feature')
176
- end
177
-
178
- it 'plans step definition conversions' do
179
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
180
- plan = described_class.new(analysis, params).build
181
-
182
- expect(plan.converted_steps.length).to eq(1)
183
- expect(plan.converted_steps.first.output_path).to eq('output/features/step_definitions/login_steps.rb')
184
- end
185
-
186
- it 'skips rspec-style test conversion for cucumber target' do
187
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
188
- plan = described_class.new(analysis, params).build
189
-
190
- expect(plan.converted_tests).to be_empty
191
- end
192
- end
193
-
194
- context 'converting capybara to selenium' do
195
- let(:params) do
196
- {
197
- source_path: project_dir,
198
- output_path: 'output',
199
- target_automation: 'selenium',
200
- target_framework: 'rspec'
201
- }
202
- end
203
-
204
- before do
205
- File.write("#{project_dir}/Gemfile", "gem 'capybara'\ngem 'rspec'\n")
206
- FileUtils.mkdir_p("#{project_dir}/pages")
207
-
208
- File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
209
- class LoginPage < BasePage
210
- include Capybara::DSL
211
- def login(email, password)
212
- fill_in 'email', with: email
213
- click_button 'Login'
214
- end
215
- end
216
- RUBY
217
- end
218
-
219
- it 'adds a warning when no converter is registered' do
220
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
221
- plan = described_class.new(analysis, params).build
222
-
223
- expect(plan.warnings).to include(match(/No converter for capybara.*selenium/))
224
- end
225
-
226
- it 'still includes the page with identity conversion' do
227
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
228
- plan = described_class.new(analysis, params).build
229
-
230
- expect(plan.converted_pages.length).to eq(1)
231
- end
232
- end
233
-
234
- context 'with config overrides' do
235
- let(:params) do
236
- {
237
- source_path: project_dir,
238
- output_path: 'output',
239
- target_automation: 'selenium',
240
- target_framework: 'rspec',
241
- browser: 'firefox',
242
- url: 'https://override.com'
243
- }
244
- end
245
-
246
- before do
247
- File.write("#{project_dir}/Gemfile", "gem 'rspec'\ngem 'selenium-webdriver'\n")
248
- FileUtils.mkdir_p("#{project_dir}/config")
249
- File.write("#{project_dir}/config/config.yml", "browser: chrome\nurl: 'https://original.com'\n")
250
- end
251
-
252
- it 'uses parameter overrides over detected values' do
253
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
254
- plan = described_class.new(analysis, params).build
255
-
256
- expect(plan.config_overrides[:browser]).to eq('firefox')
257
- expect(plan.config_overrides[:url]).to eq('https://override.com')
258
- end
259
- end
260
-
261
- context 'converting to capybara updates page instantiation' do
262
- let(:params) do
263
- {
264
- source_path: project_dir,
265
- output_path: 'output',
266
- target_automation: 'capybara',
267
- target_framework: 'cucumber'
268
- }
269
- end
270
-
271
- before do
272
- File.write("#{project_dir}/Gemfile", "gem 'cucumber'\ngem 'selenium-webdriver'\n")
273
- FileUtils.mkdir_p("#{project_dir}/features/step_definitions")
274
-
275
- File.write("#{project_dir}/features/login.feature", <<~GHERKIN)
276
- Feature: Login
277
- Scenario: Test
278
- Given I am on the login page
279
- GHERKIN
280
-
281
- File.write("#{project_dir}/features/step_definitions/login_steps.rb", <<~RUBY)
282
- Given('I am on the login page') do
283
- @page = LoginPage.new(driver)
284
- end
285
- RUBY
286
- end
287
-
288
- it 'removes driver argument from page instantiation in steps' do
289
- analysis = Adopter::ProjectAnalyzer.new(project_dir).analyze
290
- plan = described_class.new(analysis, params).build
291
-
292
- step_content = plan.converted_steps.first.content
293
- expect(step_content).to include('LoginPage.new')
294
- expect(step_content).not_to include('LoginPage.new(driver)')
295
- end
296
- end
297
- end
298
- end