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.
- checksums.yaml +4 -4
- data/.github/workflows/e2e_tests.yml +0 -17
- data/.github/workflows/system_tests.yml +0 -22
- data/README.md +8 -62
- data/lib/commands/scaffolding_commands.rb +1 -192
- data/lib/commands/utility_commands.rb +0 -43
- data/lib/generators/automation/templates/login.tt +1 -9
- data/lib/generators/automation/templates/page.tt +1 -7
- data/lib/generators/automation/templates/partials/initialize_selector.tt +1 -3
- data/lib/generators/automation/templates/partials/visit_method.tt +2 -6
- data/lib/generators/common_generator.rb +0 -6
- data/lib/generators/cucumber/cucumber_generator.rb +0 -24
- data/lib/generators/cucumber/templates/accessibility_steps.tt +2 -6
- data/lib/generators/cucumber/templates/cucumber.tt +0 -7
- data/lib/generators/cucumber/templates/env.tt +1 -3
- data/lib/generators/cucumber/templates/partials/appium_env.tt +1 -6
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +0 -5
- data/lib/generators/cucumber/templates/partials/watir_env.tt +0 -5
- data/lib/generators/cucumber/templates/partials/web_steps.tt +4 -4
- data/lib/generators/cucumber/templates/world.tt +1 -3
- data/lib/generators/generator.rb +2 -46
- data/lib/generators/helper_generator.rb +4 -42
- data/lib/generators/infrastructure/templates/github.tt +2 -2
- data/lib/generators/infrastructure/templates/github_appium.tt +2 -6
- data/lib/generators/invoke_generators.rb +4 -25
- data/lib/generators/menu_generator.rb +10 -100
- data/lib/generators/rspec/rspec_generator.rb +0 -11
- data/lib/generators/rspec/templates/accessibility_spec.tt +2 -6
- data/lib/generators/rspec/templates/spec.tt +6 -8
- data/lib/generators/templates/common/gemfile.tt +0 -26
- data/lib/generators/templates/common/git_ignore.tt +0 -2
- data/lib/generators/templates/common/partials/mobile_config.tt +0 -4
- data/lib/generators/templates/common/partials/web_config.tt +0 -4
- data/lib/generators/templates/common/rakefile.tt +0 -9
- data/lib/generators/templates/common/read_me.tt +4 -10
- data/lib/generators/templates/helpers/allure_helper.tt +0 -10
- data/lib/generators/templates/helpers/partials/debug_diagnostics.tt +1 -3
- data/lib/generators/templates/helpers/partials/debug_start.tt +1 -3
- data/lib/generators/templates/helpers/partials/quit_driver.tt +1 -3
- data/lib/generators/templates/helpers/partials/screenshot.tt +1 -3
- data/lib/generators/templates/helpers/spec_helper.tt +2 -39
- data/lib/ruby_raider.rb +2 -50
- data/lib/scaffolding/project_detector.rb +2 -9
- data/lib/scaffolding/scaffolding.rb +0 -109
- data/lib/scaffolding/templates/component.tt +1 -4
- data/lib/scaffolding/templates/page_object.tt +0 -10
- data/lib/scaffolding/templates/spec.tt +2 -6
- data/lib/scaffolding/templates/steps.tt +0 -2
- data/lib/utilities/utilities.rb +23 -29
- data/lib/version +1 -1
- data/sig/commands/scaffolding_commands.rbs +0 -12
- data/sig/commands/utility_commands.rbs +0 -6
- data/sig/generators/cucumber/cucumber_generator.rbs +0 -4
- data/sig/generators/generator.rbs +0 -11
- data/sig/generators/helper_generator.rbs +1 -5
- data/sig/generators/invoke_generators.rbs +1 -2
- data/sig/generators/menu_generator.rbs +2 -6
- data/sig/generators/rspec/rspec_generator.rbs +0 -2
- data/sig/ruby_raider.rbs +1 -3
- data/sig/scaffolding/project_detector.rbs +0 -1
- data/sig/scaffolding/scaffolding.rbs +0 -23
- data/sig/utilities/utilities.rbs +0 -4
- data/spec/commands/raider_commands_spec.rb +0 -61
- data/spec/integration/commands/browser_update_after_creation_spec.rb +123 -0
- data/spec/integration/commands/scaffolding_commands_spec.rb +0 -20
- data/spec/integration/commands/utility_commands_spec.rb +5 -5
- data/spec/integration/content/ci_content_spec.rb +6 -61
- data/spec/integration/content/common_content_spec.rb +0 -64
- data/spec/integration/content/config_content_spec.rb +1 -51
- data/spec/integration/content/content_helper.rb +2 -2
- data/spec/integration/content/gemfile_content_spec.rb +0 -71
- data/spec/integration/content/helper_content_spec.rb +4 -240
- data/spec/integration/content/page_content_spec.rb +0 -89
- data/spec/integration/content/syntax_validation_spec.rb +2 -2
- data/spec/integration/content/test_content_spec.rb +0 -119
- data/spec/integration/end_to_end_features_spec.rb +13 -411
- data/spec/integration/end_to_end_spec.rb +0 -96
- data/spec/integration/generators/axe_addon_spec.rb +2 -52
- data/spec/integration/generators/common_generator_spec.rb +1 -13
- data/spec/integration/generators/config_features_spec.rb +3 -81
- data/spec/integration/generators/debug_helper_spec.rb +0 -20
- data/spec/integration/generators/github_generator_spec.rb +5 -15
- data/spec/integration/generators/helpers_generator_spec.rb +0 -37
- data/spec/integration/scaffolding_e2e_spec.rb +2 -237
- data/spec/integration/settings_helper.rb +1 -3
- data/spec/integration/spec_helper.rb +6 -11
- data/spec/menus/menu_generator_spec.rb +4 -107
- data/spec/scaffolding/scaffold_project_detector_spec.rb +4 -26
- data/spec/scaffolding/scaffolding_features_spec.rb +0 -183
- data/spec/system/selenium_spec.rb +1 -4
- data/spec/system/support/system_test_helper.rb +0 -1
- data/spec/system/watir_spec.rb +1 -4
- data/spec/utilities/headless_config_spec.rb +0 -7
- metadata +3 -97
- data/lib/adopter/adopt_menu.rb +0 -146
- data/lib/adopter/converters/base_converter.rb +0 -84
- data/lib/adopter/converters/identity_converter.rb +0 -53
- data/lib/adopter/migration_plan.rb +0 -74
- data/lib/adopter/migrator.rb +0 -96
- data/lib/adopter/plan_builder.rb +0 -275
- data/lib/adopter/project_analyzer.rb +0 -252
- data/lib/adopter/project_detector.rb +0 -157
- data/lib/generators/cucumber/templates/partials/capybara_env.tt +0 -38
- data/lib/generators/cucumber/templates/partials/capybara_world.tt +0 -6
- data/lib/generators/cucumber/templates/performance_feature.tt +0 -5
- data/lib/generators/cucumber/templates/performance_steps.tt +0 -17
- data/lib/generators/cucumber/templates/visual_feature.tt +0 -5
- data/lib/generators/cucumber/templates/visual_steps.tt +0 -19
- data/lib/generators/infrastructure/gitlab_generator.rb +0 -11
- data/lib/generators/infrastructure/templates/gitlab.tt +0 -46
- data/lib/generators/minitest/minitest_generator.rb +0 -35
- data/lib/generators/minitest/templates/accessibility_test.tt +0 -26
- data/lib/generators/minitest/templates/performance_test.tt +0 -18
- data/lib/generators/minitest/templates/test.tt +0 -64
- data/lib/generators/minitest/templates/visual_test.tt +0 -23
- data/lib/generators/rspec/templates/performance_spec.tt +0 -18
- data/lib/generators/rspec/templates/visual_spec.tt +0 -20
- data/lib/generators/templates/helpers/capybara_helper.tt +0 -32
- data/lib/generators/templates/helpers/performance_helper.tt +0 -57
- data/lib/generators/templates/helpers/visual_helper.tt +0 -58
- data/lib/llm/client.rb +0 -79
- data/lib/llm/config.rb +0 -57
- data/lib/llm/prompts.rb +0 -84
- data/lib/llm/provider.rb +0 -27
- data/lib/llm/providers/anthropic_provider.rb +0 -43
- data/lib/llm/providers/ollama_provider.rb +0 -56
- data/lib/llm/providers/openai_provider.rb +0 -42
- data/lib/llm/response_parser.rb +0 -67
- data/lib/plugin/plugin.rb +0 -111
- data/lib/plugin/plugin_exposer.rb +0 -55
- data/lib/scaffolding/crud_generator.rb +0 -94
- data/lib/scaffolding/dry_run_presenter.rb +0 -16
- data/lib/scaffolding/page_introspector.rb +0 -45
- data/lib/scaffolding/scaffold_menu.rb +0 -103
- data/lib/scaffolding/templates/page_from_url.tt +0 -75
- data/lib/scaffolding/templates/spec_from_page.tt +0 -31
- data/lib/scaffolding/templates/spec_from_url.tt +0 -46
- data/lib/scaffolding/url_analyzer.rb +0 -179
- data/sig/adopter/adopt_menu.rbs +0 -25
- data/sig/adopter/converters/base_converter.rbs +0 -23
- data/sig/adopter/converters/identity_converter.rbs +0 -16
- data/sig/adopter/migration_plan.rbs +0 -34
- data/sig/adopter/migrator.rbs +0 -21
- data/sig/adopter/plan_builder.rbs +0 -38
- data/sig/adopter/project_analyzer.rbs +0 -39
- data/sig/adopter/project_detector.rbs +0 -26
- data/sig/generators/infrastructure/gitlab_generator.rbs +0 -4
- data/sig/generators/minitest/minitest_generator.rbs +0 -8
- data/sig/llm/client.rbs +0 -15
- data/sig/llm/config.rbs +0 -20
- data/sig/llm/prompts.rbs +0 -8
- data/sig/llm/provider.rbs +0 -12
- data/sig/llm/providers/anthropic_provider.rbs +0 -16
- data/sig/llm/providers/ollama_provider.rbs +0 -18
- data/sig/llm/providers/openai_provider.rbs +0 -16
- data/sig/llm/response_parser.rbs +0 -13
- data/sig/plugin/plugin.rbs +0 -24
- data/sig/plugin/plugin_exposer.rbs +0 -20
- data/sig/scaffolding/crud_generator.rbs +0 -16
- data/sig/scaffolding/dry_run_presenter.rbs +0 -4
- data/sig/scaffolding/page_introspector.rbs +0 -14
- data/sig/scaffolding/scaffold_menu.rbs +0 -18
- data/sig/scaffolding/url_analyzer.rbs +0 -28
- data/spec/adopter/adopt_menu_spec.rb +0 -176
- data/spec/adopter/converters/identity_converter_spec.rb +0 -145
- data/spec/adopter/migration_plan_spec.rb +0 -113
- data/spec/adopter/migrator_spec.rb +0 -277
- data/spec/adopter/plan_builder_spec.rb +0 -298
- data/spec/adopter/project_analyzer_spec.rb +0 -337
- data/spec/adopter/project_detector_spec.rb +0 -295
- data/spec/generators/generator_spec.rb +0 -23
- data/spec/integration/content/reporter_content_spec.rb +0 -236
- data/spec/integration/content/skip_flags_content_spec.rb +0 -206
- data/spec/integration/generators/gitlab_generator_spec.rb +0 -38
- data/spec/integration/generators/lighthouse_addon_spec.rb +0 -132
- data/spec/integration/generators/minitest_generator_spec.rb +0 -64
- data/spec/integration/generators/reporter_spec.rb +0 -159
- data/spec/integration/generators/skip_flags_spec.rb +0 -134
- data/spec/integration/generators/visual_addon_spec.rb +0 -148
- data/spec/llm/client_spec.rb +0 -79
- data/spec/llm/config_spec.rb +0 -92
- data/spec/llm/prompts_spec.rb +0 -49
- data/spec/llm/response_parser_spec.rb +0 -92
- data/spec/menus/adopter_adopt_menu_spec.rb +0 -97
- data/spec/scaffolding/page_introspector_spec.rb +0 -82
- data/spec/scaffolding/url_analyzer_spec.rb +0 -110
- data/spec/system/adopt_matrix_spec.rb +0 -537
- data/spec/system/adopt_spec.rb +0 -225
- data/spec/system/capybara_spec.rb +0 -42
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
require 'rspec'
|
|
5
|
-
require_relative '../../lib/adopter/project_analyzer'
|
|
6
|
-
|
|
7
|
-
RSpec.describe Adopter::ProjectAnalyzer do
|
|
8
|
-
let(:project_dir) { 'tmp_analyzer_project' }
|
|
9
|
-
|
|
10
|
-
before { FileUtils.mkdir_p(project_dir) }
|
|
11
|
-
|
|
12
|
-
after { FileUtils.rm_rf(project_dir) }
|
|
13
|
-
|
|
14
|
-
describe '#analyze' do
|
|
15
|
-
context 'with a selenium + rspec project' do
|
|
16
|
-
before do
|
|
17
|
-
File.write("#{project_dir}/Gemfile", <<~GEMFILE)
|
|
18
|
-
gem 'rspec'
|
|
19
|
-
gem 'selenium-webdriver'
|
|
20
|
-
gem 'faker'
|
|
21
|
-
gem 'httparty'
|
|
22
|
-
GEMFILE
|
|
23
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
24
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
25
|
-
|
|
26
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
27
|
-
class LoginPage < BasePage
|
|
28
|
-
def login(username, password)
|
|
29
|
-
driver.find_element(id: 'user').send_keys username
|
|
30
|
-
driver.find_element(id: 'pass').send_keys password
|
|
31
|
-
driver.find_element(id: 'submit').click
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
private
|
|
35
|
-
|
|
36
|
-
def username_field
|
|
37
|
-
driver.find_element(id: 'user')
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
RUBY
|
|
41
|
-
|
|
42
|
-
File.write("#{project_dir}/spec/login_spec.rb", <<~RUBY)
|
|
43
|
-
describe 'Login' do
|
|
44
|
-
let(:login_page) { LoginPage.new(driver) }
|
|
45
|
-
|
|
46
|
-
it 'can log in with valid credentials' do
|
|
47
|
-
expect(header).to eq 'Welcome'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it 'shows error with invalid credentials' do
|
|
51
|
-
expect(error).to eq 'Invalid'
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
RUBY
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'returns a complete analysis hash' do
|
|
58
|
-
analysis = described_class.new(project_dir).analyze
|
|
59
|
-
expect(analysis).to include(
|
|
60
|
-
automation: 'selenium',
|
|
61
|
-
framework: 'rspec',
|
|
62
|
-
source_dsl: :selenium
|
|
63
|
-
)
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'discovers page objects' do
|
|
67
|
-
analysis = described_class.new(project_dir).analyze
|
|
68
|
-
expect(analysis[:pages].length).to eq(1)
|
|
69
|
-
expect(analysis[:pages].first).to include(
|
|
70
|
-
class_name: 'LoginPage',
|
|
71
|
-
base_class: 'BasePage'
|
|
72
|
-
)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it 'extracts public methods from pages' do
|
|
76
|
-
analysis = described_class.new(project_dir).analyze
|
|
77
|
-
expect(analysis[:pages].first[:methods]).to eq(['login'])
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it 'discovers test files' do
|
|
81
|
-
analysis = described_class.new(project_dir).analyze
|
|
82
|
-
expect(analysis[:tests].length).to eq(1)
|
|
83
|
-
expect(analysis[:tests].first[:type]).to eq(:rspec)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'extracts test method names' do
|
|
87
|
-
analysis = described_class.new(project_dir).analyze
|
|
88
|
-
expect(analysis[:tests].first[:test_methods]).to include(
|
|
89
|
-
'can log in with valid credentials',
|
|
90
|
-
'shows error with invalid credentials'
|
|
91
|
-
)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'identifies custom gems' do
|
|
95
|
-
analysis = described_class.new(project_dir).analyze
|
|
96
|
-
expect(analysis[:custom_gems]).to contain_exactly('faker', 'httparty')
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context 'with a capybara/site_prism project' do
|
|
101
|
-
before do
|
|
102
|
-
File.write("#{project_dir}/Gemfile", <<~GEMFILE)
|
|
103
|
-
gem 'capybara'
|
|
104
|
-
gem 'site_prism'
|
|
105
|
-
gem 'rspec'
|
|
106
|
-
gem 'selenium-webdriver'
|
|
107
|
-
GEMFILE
|
|
108
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
109
|
-
|
|
110
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
111
|
-
class LoginPage < SitePrism::Page
|
|
112
|
-
set_url '/login'
|
|
113
|
-
element :email_field, '#email'
|
|
114
|
-
element :password_field, '#password'
|
|
115
|
-
end
|
|
116
|
-
RUBY
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it 'detects site_prism dsl' do
|
|
120
|
-
analysis = described_class.new(project_dir).analyze
|
|
121
|
-
expect(analysis[:source_dsl]).to eq(:site_prism)
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it 'detects capybara automation' do
|
|
125
|
-
analysis = described_class.new(project_dir).analyze
|
|
126
|
-
expect(analysis[:automation]).to eq('capybara')
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
context 'with a capybara DSL project (no site_prism)' do
|
|
131
|
-
before do
|
|
132
|
-
File.write("#{project_dir}/Gemfile", <<~GEMFILE)
|
|
133
|
-
gem 'capybara'
|
|
134
|
-
gem 'rspec'
|
|
135
|
-
GEMFILE
|
|
136
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
137
|
-
|
|
138
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
139
|
-
class LoginPage < BasePage
|
|
140
|
-
include Capybara::DSL
|
|
141
|
-
|
|
142
|
-
def login(email, password)
|
|
143
|
-
fill_in 'email', with: email
|
|
144
|
-
fill_in 'password', with: password
|
|
145
|
-
click_button 'Login'
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
RUBY
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it 'detects capybara dsl' do
|
|
152
|
-
analysis = described_class.new(project_dir).analyze
|
|
153
|
-
expect(analysis[:source_dsl]).to eq(:capybara)
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
context 'with a watir project' do
|
|
158
|
-
before do
|
|
159
|
-
File.write("#{project_dir}/Gemfile", "gem 'watir'\ngem 'rspec'\n")
|
|
160
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
161
|
-
|
|
162
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
163
|
-
class LoginPage < Page
|
|
164
|
-
def login(username, password)
|
|
165
|
-
browser.text_field(id: 'user').set username
|
|
166
|
-
browser.button(id: 'submit').click
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
RUBY
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it 'detects watir dsl' do
|
|
173
|
-
analysis = described_class.new(project_dir).analyze
|
|
174
|
-
expect(analysis[:source_dsl]).to eq(:watir)
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
context 'with a minitest project' do
|
|
179
|
-
before do
|
|
180
|
-
File.write("#{project_dir}/Gemfile", "gem 'minitest'\ngem 'selenium-webdriver'\n")
|
|
181
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
182
|
-
FileUtils.mkdir_p("#{project_dir}/test")
|
|
183
|
-
|
|
184
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
185
|
-
class LoginPage < BasePage
|
|
186
|
-
def login(u, p)
|
|
187
|
-
driver.find_element(id: 'user').send_keys u
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
RUBY
|
|
191
|
-
|
|
192
|
-
File.write("#{project_dir}/test/test_login.rb", <<~RUBY)
|
|
193
|
-
class TestLogin < Minitest::Test
|
|
194
|
-
def test_successful_login
|
|
195
|
-
assert_equal 'Welcome', header
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def test_failed_login
|
|
199
|
-
assert_equal 'Error', message
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
RUBY
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
it 'discovers minitest files' do
|
|
206
|
-
analysis = described_class.new(project_dir).analyze
|
|
207
|
-
expect(analysis[:tests].length).to eq(1)
|
|
208
|
-
expect(analysis[:tests].first[:type]).to eq(:minitest)
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
it 'extracts minitest method names' do
|
|
212
|
-
analysis = described_class.new(project_dir).analyze
|
|
213
|
-
expect(analysis[:tests].first[:test_methods]).to contain_exactly(
|
|
214
|
-
'test_successful_login', 'test_failed_login'
|
|
215
|
-
)
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
context 'with a cucumber project' do
|
|
220
|
-
before do
|
|
221
|
-
File.write("#{project_dir}/Gemfile", "gem 'cucumber'\ngem 'selenium-webdriver'\n")
|
|
222
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
223
|
-
FileUtils.mkdir_p("#{project_dir}/features/step_definitions")
|
|
224
|
-
|
|
225
|
-
File.write("#{project_dir}/pages/login_page.rb", <<~RUBY)
|
|
226
|
-
class LoginPage < BasePage
|
|
227
|
-
def login(u, p)
|
|
228
|
-
driver.find_element(id: 'user').send_keys u
|
|
229
|
-
end
|
|
230
|
-
end
|
|
231
|
-
RUBY
|
|
232
|
-
|
|
233
|
-
File.write("#{project_dir}/features/login.feature", <<~GHERKIN)
|
|
234
|
-
Feature: Login
|
|
235
|
-
|
|
236
|
-
Scenario: Successful login
|
|
237
|
-
Given I am on the login page
|
|
238
|
-
When I enter valid credentials
|
|
239
|
-
Then I see the dashboard
|
|
240
|
-
|
|
241
|
-
Scenario: Failed login
|
|
242
|
-
Given I am on the login page
|
|
243
|
-
When I enter invalid credentials
|
|
244
|
-
Then I see an error
|
|
245
|
-
GHERKIN
|
|
246
|
-
|
|
247
|
-
File.write("#{project_dir}/features/step_definitions/login_steps.rb", <<~RUBY)
|
|
248
|
-
Given('I am on the login page') do
|
|
249
|
-
visit '/login'
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
When('I enter valid credentials') do
|
|
253
|
-
fill_in 'email', with: 'test@test.com'
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
Then('I see the dashboard') do
|
|
257
|
-
expect(page).to have_content 'Dashboard'
|
|
258
|
-
end
|
|
259
|
-
RUBY
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
it 'discovers feature files' do
|
|
263
|
-
analysis = described_class.new(project_dir).analyze
|
|
264
|
-
expect(analysis[:features].length).to eq(1)
|
|
265
|
-
expect(analysis[:features].first[:scenarios]).to eq(2)
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
it 'discovers step definitions' do
|
|
269
|
-
analysis = described_class.new(project_dir).analyze
|
|
270
|
-
expect(analysis[:step_definitions].length).to eq(1)
|
|
271
|
-
expect(analysis[:step_definitions].first[:steps]).to eq(3)
|
|
272
|
-
end
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
context 'with an appium project' do
|
|
276
|
-
before do
|
|
277
|
-
File.write("#{project_dir}/Gemfile", "gem 'appium_lib'\ngem 'rspec'\n")
|
|
278
|
-
end
|
|
279
|
-
|
|
280
|
-
it 'raises MobileProjectError' do
|
|
281
|
-
expect { described_class.new(project_dir).analyze }
|
|
282
|
-
.to raise_error(Adopter::MobileProjectError, /Mobile.*cannot be adopted/)
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
context 'with overrides' do
|
|
287
|
-
before do
|
|
288
|
-
File.write("#{project_dir}/Gemfile", "gem 'rspec'\ngem 'selenium-webdriver'\n")
|
|
289
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
it 'applies overrides to detection' do
|
|
293
|
-
analysis = described_class.new(project_dir, browser: 'firefox').analyze
|
|
294
|
-
expect(analysis[:browser]).to eq('firefox')
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
context 'with helpers' do
|
|
299
|
-
before do
|
|
300
|
-
File.write("#{project_dir}/Gemfile", "gem 'rspec'\ngem 'selenium-webdriver'\n")
|
|
301
|
-
FileUtils.mkdir_p("#{project_dir}/spec/support")
|
|
302
|
-
|
|
303
|
-
File.write("#{project_dir}/spec/support/driver_setup.rb", <<~RUBY)
|
|
304
|
-
module DriverHelper
|
|
305
|
-
def driver
|
|
306
|
-
@driver ||= Selenium::WebDriver.for :chrome
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
def create_driver
|
|
310
|
-
Selenium::WebDriver.for :chrome
|
|
311
|
-
end
|
|
312
|
-
end
|
|
313
|
-
RUBY
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
it 'discovers helpers with roles' do
|
|
317
|
-
analysis = described_class.new(project_dir).analyze
|
|
318
|
-
driver_helper = analysis[:helpers].find { |h| h[:role] == :driver }
|
|
319
|
-
expect(driver_helper).not_to be_nil
|
|
320
|
-
expect(driver_helper[:modules_defined]).to include('DriverHelper')
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
context 'with no page objects' do
|
|
325
|
-
before do
|
|
326
|
-
File.write("#{project_dir}/Gemfile", "gem 'rspec'\ngem 'selenium-webdriver'\n")
|
|
327
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
it 'returns empty pages and raw dsl' do
|
|
331
|
-
analysis = described_class.new(project_dir).analyze
|
|
332
|
-
expect(analysis[:pages]).to eq([])
|
|
333
|
-
expect(analysis[:source_dsl]).to eq(:raw)
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
end
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'fileutils'
|
|
4
|
-
require 'rspec'
|
|
5
|
-
require_relative '../../lib/adopter/project_detector'
|
|
6
|
-
|
|
7
|
-
RSpec.describe Adopter::ProjectDetector do
|
|
8
|
-
let(:project_dir) { 'tmp_test_project' }
|
|
9
|
-
|
|
10
|
-
before { FileUtils.mkdir_p(project_dir) }
|
|
11
|
-
|
|
12
|
-
after { FileUtils.rm_rf(project_dir) }
|
|
13
|
-
|
|
14
|
-
describe '.detect' do
|
|
15
|
-
it 'returns a hash with detection results' do
|
|
16
|
-
expect(described_class.detect(project_dir)).to be_a(Hash)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'excludes nil values from the result' do
|
|
20
|
-
expect(described_class.detect(project_dir).values).not_to include(nil)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe '.detect_framework' do
|
|
25
|
-
subject(:framework) { described_class.detect_framework(project_dir) }
|
|
26
|
-
|
|
27
|
-
context 'when Gemfile contains rspec' do
|
|
28
|
-
before { File.write("#{project_dir}/Gemfile", "gem 'rspec'\n") }
|
|
29
|
-
|
|
30
|
-
it { is_expected.to eq('rspec') }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'when Gemfile contains cucumber' do
|
|
34
|
-
before { File.write("#{project_dir}/Gemfile", "gem 'cucumber'\n") }
|
|
35
|
-
|
|
36
|
-
it { is_expected.to eq('cucumber') }
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
context 'when Gemfile contains minitest' do
|
|
40
|
-
before { File.write("#{project_dir}/Gemfile", "gem 'minitest'\n") }
|
|
41
|
-
|
|
42
|
-
it { is_expected.to eq('minitest') }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
context 'when no Gemfile but spec/ exists' do
|
|
46
|
-
before { FileUtils.mkdir_p("#{project_dir}/spec") }
|
|
47
|
-
|
|
48
|
-
it { is_expected.to eq('rspec') }
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'when no Gemfile but features/ exists' do
|
|
52
|
-
before { FileUtils.mkdir_p("#{project_dir}/features") }
|
|
53
|
-
|
|
54
|
-
it { is_expected.to eq('cucumber') }
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context 'when no Gemfile but test/ exists' do
|
|
58
|
-
before { FileUtils.mkdir_p("#{project_dir}/test") }
|
|
59
|
-
|
|
60
|
-
it { is_expected.to eq('minitest') }
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
context 'when nothing is present' do
|
|
64
|
-
it { is_expected.to be_nil }
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
describe '.detect_automation' do
|
|
69
|
-
subject(:automation) { described_class.detect_automation(project_dir) }
|
|
70
|
-
|
|
71
|
-
%w[selenium-webdriver watir appium_lib].zip(%w[selenium watir appium]).each do |gem_name, expected|
|
|
72
|
-
context "with #{gem_name} in Gemfile" do
|
|
73
|
-
before { File.write("#{project_dir}/Gemfile", "gem '#{gem_name}'\n") }
|
|
74
|
-
|
|
75
|
-
it { is_expected.to eq(expected) }
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
{ 'eyes_selenium' => 'selenium', 'axe-core-selenium' => 'selenium',
|
|
80
|
-
'capybara' => 'capybara', 'site_prism' => 'capybara' }.each do |gem_name, expected|
|
|
81
|
-
context "with #{gem_name} in Gemfile" do
|
|
82
|
-
before { File.write("#{project_dir}/Gemfile", "gem '#{gem_name}'\n") }
|
|
83
|
-
|
|
84
|
-
it { is_expected.to eq(expected) }
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
context 'with capybara and selenium-webdriver in Gemfile' do
|
|
89
|
-
before { File.write("#{project_dir}/Gemfile", "gem 'capybara'\ngem 'selenium-webdriver'\n") }
|
|
90
|
-
|
|
91
|
-
it 'prioritizes capybara over selenium' do
|
|
92
|
-
expect(automation).to eq('capybara')
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
context 'with no Gemfile but require in source files' do
|
|
97
|
-
before do
|
|
98
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
99
|
-
File.write("#{project_dir}/spec/test.rb", "require 'selenium-webdriver'\n")
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it { is_expected.to eq('selenium') }
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context 'with no Gemfile but capybara require in source files' do
|
|
106
|
-
before do
|
|
107
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
108
|
-
File.write("#{project_dir}/spec/test.rb", "require 'capybara'\n")
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it { is_expected.to eq('capybara') }
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
context 'with no Gemfile but site_prism require in source files' do
|
|
115
|
-
before do
|
|
116
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
117
|
-
File.write("#{project_dir}/spec/test.rb", "require 'site_prism'\n")
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it { is_expected.to eq('capybara') }
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
describe '.detect_page_path' do
|
|
125
|
-
subject(:page_path) { described_class.detect_page_path(project_dir) }
|
|
126
|
-
|
|
127
|
-
{ 'page_objects/pages' => 'page_objects/pages', 'pages' => 'pages', 'page' => 'page' }.each do |dir, expected|
|
|
128
|
-
context "with #{dir} directory" do
|
|
129
|
-
before { FileUtils.mkdir_p("#{project_dir}/#{dir}") }
|
|
130
|
-
|
|
131
|
-
it { is_expected.to eq(expected) }
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
describe '.detect_spec_path' do
|
|
137
|
-
subject(:spec_path) { described_class.detect_spec_path(project_dir) }
|
|
138
|
-
|
|
139
|
-
{ 'spec' => 'spec', 'test' => 'test', 'tests' => 'tests' }.each do |dir, expected|
|
|
140
|
-
context "with #{dir} directory" do
|
|
141
|
-
before { FileUtils.mkdir_p("#{project_dir}/#{dir}") }
|
|
142
|
-
|
|
143
|
-
it { is_expected.to eq(expected) }
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
describe '.detect_feature_path' do
|
|
149
|
-
context 'with features directory' do
|
|
150
|
-
before { FileUtils.mkdir_p("#{project_dir}/features") }
|
|
151
|
-
|
|
152
|
-
it 'detects features path' do
|
|
153
|
-
expect(described_class.detect_feature_path(project_dir)).to eq('features')
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
describe '.detect_helper_path' do
|
|
159
|
-
subject(:helper_path) { described_class.detect_helper_path(project_dir) }
|
|
160
|
-
|
|
161
|
-
{ 'helpers' => 'helpers', 'support' => 'support', 'features/support' => 'features/support' }.each do |dir, expected|
|
|
162
|
-
context "with #{dir} directory" do
|
|
163
|
-
before { FileUtils.mkdir_p("#{project_dir}/#{dir}") }
|
|
164
|
-
|
|
165
|
-
it { is_expected.to eq(expected) }
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
describe '.detect_browser' do
|
|
171
|
-
subject(:browser) { described_class.detect_browser(project_dir) }
|
|
172
|
-
|
|
173
|
-
context 'with browser in spec_helper' do
|
|
174
|
-
before do
|
|
175
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
176
|
-
File.write("#{project_dir}/spec/spec_helper.rb", "browser = :firefox\n")
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it { is_expected.to eq('firefox') }
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
context 'with browser in config.yml' do
|
|
183
|
-
before do
|
|
184
|
-
FileUtils.mkdir_p("#{project_dir}/config")
|
|
185
|
-
File.write("#{project_dir}/config/config.yml", "browser: chrome\n")
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it { is_expected.to eq('chrome') }
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
describe '.detect_url' do
|
|
193
|
-
subject(:url) { described_class.detect_url(project_dir) }
|
|
194
|
-
|
|
195
|
-
context 'with base_url in spec_helper' do
|
|
196
|
-
before do
|
|
197
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
198
|
-
File.write("#{project_dir}/spec/spec_helper.rb", "base_url = 'https://example.com'\n")
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
it { is_expected.to eq('https://example.com') }
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
context 'with app_host in env.rb' do
|
|
205
|
-
before do
|
|
206
|
-
FileUtils.mkdir_p("#{project_dir}/features/support")
|
|
207
|
-
File.write("#{project_dir}/features/support/env.rb", "app_host = 'https://staging.example.com'\n")
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
it { is_expected.to eq('https://staging.example.com') }
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
describe '.detect_ci_platform' do
|
|
215
|
-
subject(:ci_platform) { described_class.detect_ci_platform(project_dir) }
|
|
216
|
-
|
|
217
|
-
context 'with .github/workflows directory' do
|
|
218
|
-
before { FileUtils.mkdir_p("#{project_dir}/.github/workflows") }
|
|
219
|
-
|
|
220
|
-
it { is_expected.to eq('github') }
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
context 'with .gitlab-ci.yml file' do
|
|
224
|
-
before { File.write("#{project_dir}/.gitlab-ci.yml", "stages:\n - test\n") }
|
|
225
|
-
|
|
226
|
-
it { is_expected.to eq('gitlab') }
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
context 'with no CI configuration' do
|
|
230
|
-
it { is_expected.to be_nil }
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
describe 'full project detection' do
|
|
235
|
-
before do
|
|
236
|
-
File.write("#{project_dir}/Gemfile", <<~GEMFILE)
|
|
237
|
-
source 'https://rubygems.org'
|
|
238
|
-
gem 'rspec'
|
|
239
|
-
gem 'selenium-webdriver'
|
|
240
|
-
gem 'rake'
|
|
241
|
-
GEMFILE
|
|
242
|
-
FileUtils.mkdir_p("#{project_dir}/spec")
|
|
243
|
-
FileUtils.mkdir_p("#{project_dir}/page_objects/pages")
|
|
244
|
-
FileUtils.mkdir_p("#{project_dir}/helpers")
|
|
245
|
-
FileUtils.mkdir_p("#{project_dir}/.github/workflows")
|
|
246
|
-
FileUtils.mkdir_p("#{project_dir}/config")
|
|
247
|
-
File.write("#{project_dir}/config/config.yml", "browser: chrome\nurl: 'https://example.com'\n")
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it 'detects all components of a complete project' do
|
|
251
|
-
expect(described_class.detect(project_dir)).to include(
|
|
252
|
-
automation: 'selenium',
|
|
253
|
-
framework: 'rspec',
|
|
254
|
-
page_path: 'page_objects/pages',
|
|
255
|
-
spec_path: 'spec',
|
|
256
|
-
helper_path: 'helpers',
|
|
257
|
-
browser: 'chrome',
|
|
258
|
-
url: 'https://example.com',
|
|
259
|
-
ci_platform: 'github'
|
|
260
|
-
)
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
describe 'full capybara + minitest project detection' do
|
|
265
|
-
before do
|
|
266
|
-
File.write("#{project_dir}/Gemfile", <<~GEMFILE)
|
|
267
|
-
source 'https://rubygems.org'
|
|
268
|
-
gem 'minitest'
|
|
269
|
-
gem 'capybara'
|
|
270
|
-
gem 'selenium-webdriver'
|
|
271
|
-
gem 'site_prism'
|
|
272
|
-
gem 'rake'
|
|
273
|
-
GEMFILE
|
|
274
|
-
FileUtils.mkdir_p("#{project_dir}/test")
|
|
275
|
-
FileUtils.mkdir_p("#{project_dir}/pages")
|
|
276
|
-
FileUtils.mkdir_p("#{project_dir}/support")
|
|
277
|
-
File.write("#{project_dir}/.gitlab-ci.yml", "stages:\n - test\n")
|
|
278
|
-
FileUtils.mkdir_p("#{project_dir}/config")
|
|
279
|
-
File.write("#{project_dir}/config/config.yml", "browser: firefox\nurl: 'https://staging.example.com'\n")
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
it 'detects capybara + minitest project' do
|
|
283
|
-
expect(described_class.detect(project_dir)).to include(
|
|
284
|
-
automation: 'capybara',
|
|
285
|
-
framework: 'minitest',
|
|
286
|
-
page_path: 'pages',
|
|
287
|
-
spec_path: 'test',
|
|
288
|
-
helper_path: 'support',
|
|
289
|
-
browser: 'firefox',
|
|
290
|
-
url: 'https://staging.example.com',
|
|
291
|
-
ci_platform: 'gitlab'
|
|
292
|
-
)
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rspec'
|
|
4
|
-
require_relative '../../lib/generators/generator'
|
|
5
|
-
|
|
6
|
-
RSpec.describe Generator do
|
|
7
|
-
describe '#ruby_version' do
|
|
8
|
-
it 'returns the default version when no ruby_version arg is present' do
|
|
9
|
-
generator = described_class.new(%w[selenium rspec test_project])
|
|
10
|
-
expect(generator.ruby_version).to eq('3.4')
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it 'returns the specified version from args' do
|
|
14
|
-
generator = described_class.new(%w[selenium rspec test_project ruby_version:3.3])
|
|
15
|
-
expect(generator.ruby_version).to eq('3.3')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it 'handles version with multiple colons gracefully' do
|
|
19
|
-
generator = described_class.new(%w[selenium rspec test_project ruby_version:3.2])
|
|
20
|
-
expect(generator.ruby_version).to eq('3.2')
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|