ruby_raider 1.1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/integration.yml +4 -6
- data/.github/workflows/reek.yml +6 -5
- data/.github/workflows/release.yml +175 -0
- data/.github/workflows/rubocop.yml +7 -6
- data/.github/workflows/system_tests.yml +83 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +24 -0
- data/README.md +3 -1
- data/RELEASE.md +412 -0
- data/RELEASE_QUICK_GUIDE.md +77 -0
- data/bin/release +186 -0
- data/lib/adopter/adopt_menu.rb +150 -0
- data/lib/adopter/converters/base_converter.rb +85 -0
- data/lib/adopter/converters/identity_converter.rb +56 -0
- data/lib/adopter/migration_plan.rb +75 -0
- data/lib/adopter/migrator.rb +96 -0
- data/lib/adopter/plan_builder.rb +278 -0
- data/lib/adopter/project_analyzer.rb +256 -0
- data/lib/adopter/project_detector.rb +159 -0
- data/lib/commands/adopt_commands.rb +43 -0
- data/lib/generators/automation/templates/account.tt +9 -5
- data/lib/generators/automation/templates/appium_caps.tt +60 -6
- data/lib/generators/automation/templates/home.tt +4 -4
- data/lib/generators/automation/templates/login.tt +61 -4
- data/lib/generators/automation/templates/page.tt +13 -7
- data/lib/generators/automation/templates/partials/home_page_selector.tt +4 -4
- data/lib/generators/automation/templates/partials/initialize_selector.tt +3 -1
- data/lib/generators/automation/templates/partials/pdp_page_selector.tt +4 -4
- data/lib/generators/automation/templates/partials/visit_method.tt +11 -1
- data/lib/generators/automation/templates/pdp.tt +1 -1
- data/lib/generators/cucumber/templates/env.tt +6 -4
- data/lib/generators/cucumber/templates/partials/capybara_env.tt +20 -0
- data/lib/generators/cucumber/templates/partials/capybara_world.tt +6 -0
- data/lib/generators/cucumber/templates/partials/mobile_steps.tt +2 -2
- data/lib/generators/cucumber/templates/partials/web_steps.tt +4 -3
- data/lib/generators/cucumber/templates/steps.tt +2 -2
- data/lib/generators/cucumber/templates/world.tt +5 -3
- data/lib/generators/generator.rb +14 -2
- data/lib/generators/helper_generator.rb +16 -3
- data/lib/generators/infrastructure/github_generator.rb +6 -0
- data/lib/generators/infrastructure/templates/github.tt +11 -7
- data/lib/generators/infrastructure/templates/github_appium.tt +108 -0
- data/lib/generators/infrastructure/templates/gitlab.tt +5 -2
- data/lib/generators/invoke_generators.rb +1 -0
- data/lib/generators/menu_generator.rb +2 -0
- data/lib/generators/minitest/minitest_generator.rb +23 -0
- data/lib/generators/minitest/templates/test.tt +93 -0
- data/lib/generators/rspec/templates/spec.tt +12 -10
- data/lib/generators/template_renderer/partial_cache.rb +116 -0
- data/lib/generators/template_renderer/partial_resolver.rb +103 -0
- data/lib/generators/template_renderer/template_error.rb +50 -0
- data/lib/generators/template_renderer.rb +90 -0
- data/lib/generators/templates/common/config.tt +2 -2
- data/lib/generators/templates/common/gemfile.tt +15 -3
- data/lib/generators/templates/common/partials/web_config.tt +1 -1
- data/lib/generators/templates/common/read_me.tt +3 -1
- data/lib/generators/templates/helpers/allure_helper.tt +2 -2
- data/lib/generators/templates/helpers/browser_helper.tt +1 -0
- data/lib/generators/templates/helpers/capybara_helper.tt +28 -0
- data/lib/generators/templates/helpers/driver_helper.tt +1 -1
- data/lib/generators/templates/helpers/partials/allure_imports.tt +3 -1
- data/lib/generators/templates/helpers/partials/allure_requirements.tt +3 -1
- data/lib/generators/templates/helpers/partials/appium_driver.tt +46 -0
- data/lib/generators/templates/helpers/partials/axe_driver.tt +10 -0
- data/lib/generators/templates/helpers/partials/browserstack_config.tt +13 -0
- data/lib/generators/templates/helpers/partials/driver_and_options.tt +6 -114
- data/lib/generators/templates/helpers/partials/quit_driver.tt +3 -1
- data/lib/generators/templates/helpers/partials/screenshot.tt +3 -1
- data/lib/generators/templates/helpers/partials/selenium_driver.tt +25 -0
- data/lib/generators/templates/helpers/spec_helper.tt +17 -4
- data/lib/generators/templates/helpers/test_helper.tt +26 -0
- data/lib/generators/templates/helpers/visual_spec_helper.tt +1 -1
- data/lib/ruby_raider.rb +5 -0
- data/lib/version +1 -1
- data/spec/adopter/adopt_menu_spec.rb +176 -0
- data/spec/adopter/converters/identity_converter_spec.rb +145 -0
- data/spec/adopter/migration_plan_spec.rb +113 -0
- data/spec/adopter/migrator_spec.rb +277 -0
- data/spec/adopter/plan_builder_spec.rb +298 -0
- data/spec/adopter/project_analyzer_spec.rb +337 -0
- data/spec/adopter/project_detector_spec.rb +295 -0
- data/spec/generators/fixtures/templates/test.tt +1 -0
- data/spec/generators/fixtures/templates/test_partial.tt +1 -0
- data/spec/generators/template_renderer_spec.rb +298 -0
- data/spec/integration/commands/scaffolding_commands_spec.rb +2 -2
- data/spec/integration/commands/utility_commands_spec.rb +2 -2
- data/spec/integration/end_to_end_spec.rb +325 -0
- data/spec/integration/generators/automation_generator_spec.rb +11 -11
- data/spec/integration/generators/common_generator_spec.rb +40 -40
- data/spec/integration/generators/cucumber_generator_spec.rb +7 -7
- data/spec/integration/generators/github_generator_spec.rb +8 -8
- data/spec/integration/generators/gitlab_generator_spec.rb +8 -8
- data/spec/integration/generators/helpers_generator_spec.rb +73 -35
- data/spec/integration/generators/minitest_generator_spec.rb +70 -0
- data/spec/integration/generators/rspec_generator_spec.rb +7 -7
- data/spec/integration/settings_helper.rb +1 -1
- data/spec/integration/spec_helper.rb +20 -2
- data/spec/system/capybara_spec.rb +42 -0
- data/spec/system/selenium_spec.rb +19 -17
- data/spec/system/support/system_test_helper.rb +35 -0
- data/spec/system/watir_spec.rb +19 -17
- metadata +46 -16
- data/.github/workflows/push_gem.yml +0 -37
- data/.github/workflows/selenium.yml +0 -22
- data/.github/workflows/watir.yml +0 -22
- data/lib/generators/automation/templates/partials/android_caps.tt +0 -17
- data/lib/generators/automation/templates/partials/cross_platform_caps.tt +0 -25
- data/lib/generators/automation/templates/partials/ios_caps.tt +0 -18
- data/lib/generators/automation/templates/partials/selenium_account.tt +0 -9
- data/lib/generators/automation/templates/partials/selenium_login.tt +0 -34
- data/lib/generators/automation/templates/partials/watir_account.tt +0 -7
- data/lib/generators/automation/templates/partials/watir_login.tt +0 -32
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thor'
|
|
4
|
+
require_relative '../adopter/adopt_menu'
|
|
5
|
+
|
|
6
|
+
# :reek:FeatureEnvy { enabled: false }
|
|
7
|
+
class AdoptCommands < Thor
|
|
8
|
+
desc 'project [SOURCE_PATH]', 'Adopts an existing test project into Ruby Raider conventions'
|
|
9
|
+
option :parameters,
|
|
10
|
+
type: :hash, required: false,
|
|
11
|
+
desc: 'Parameters to bypass the menu (output_path, target_automation, target_framework, ci_platform)',
|
|
12
|
+
aliases: 'p'
|
|
13
|
+
|
|
14
|
+
def project(source_path)
|
|
15
|
+
params = options[:parameters]
|
|
16
|
+
if params
|
|
17
|
+
parsed = params.transform_keys(&:to_sym)
|
|
18
|
+
parsed[:source_path] = source_path
|
|
19
|
+
result = Adopter::AdoptMenu.adopt(parsed)
|
|
20
|
+
print_programmatic_results(result)
|
|
21
|
+
else
|
|
22
|
+
Adopter::AdoptMenu.new.run
|
|
23
|
+
end
|
|
24
|
+
rescue Adopter::MobileProjectError => e
|
|
25
|
+
puts "Error: #{e.message}"
|
|
26
|
+
exit 1
|
|
27
|
+
rescue ArgumentError => e
|
|
28
|
+
puts "Invalid parameters: #{e.message}"
|
|
29
|
+
exit 1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def print_programmatic_results(result)
|
|
35
|
+
plan = result[:plan]
|
|
36
|
+
results = result[:results]
|
|
37
|
+
puts "Adoption complete: #{results[:pages]} pages, #{results[:tests]} tests, " \
|
|
38
|
+
"#{results[:features]} features, #{results[:steps]} steps"
|
|
39
|
+
puts "Warnings: #{plan.warnings.join('; ')}" unless plan.warnings.empty?
|
|
40
|
+
puts "Errors: #{results[:errors].join('; ')}" unless results[:errors].empty?
|
|
41
|
+
puts "Output: #{plan.output_path}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../abstract/page'
|
|
4
|
+
|
|
5
|
+
class Account < Page
|
|
6
|
+
def url(_page)
|
|
7
|
+
'index.php?rt=account/account'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,7 +1,61 @@
|
|
|
1
|
-
<% if
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<% if cross_platform? %>android:
|
|
2
|
+
platformName: Android
|
|
3
|
+
appium:options:
|
|
4
|
+
platformVersion: '14'
|
|
5
|
+
automationName: UiAutomator2
|
|
6
|
+
deviceName: Pixel 8 API 34
|
|
7
|
+
app: app-release.apk
|
|
8
|
+
ios:
|
|
9
|
+
platformName: iOS
|
|
10
|
+
appium:options:
|
|
11
|
+
platformVersion: '17.0'
|
|
12
|
+
deviceName: iPhone 15
|
|
13
|
+
automationName: XCUITest
|
|
14
|
+
app: RaiderTestApp.app
|
|
15
|
+
autoDismissAlerts: true
|
|
16
|
+
|
|
17
|
+
browserstack:
|
|
18
|
+
platformName: Android
|
|
19
|
+
os_version: '9.0'
|
|
20
|
+
deviceName: Google Pixel 3
|
|
21
|
+
app: app: <%= ENV['APP_URL'] %>
|
|
22
|
+
browserstack.user: <%= ENV['BROWSERSTACK_USER'] %>
|
|
23
|
+
browserstack.key: <%= ENV['BROWSERSTACK_KEY'] %>
|
|
24
|
+
project: 'RaiderTestApp'
|
|
25
|
+
name: 'RaiderTestApp-Android'
|
|
26
|
+
<% elsif ios? %>platformName: iOS
|
|
27
|
+
appium:options:
|
|
28
|
+
url: http://localhost:4723/wd/hub
|
|
29
|
+
platformVersion: '17.0'
|
|
30
|
+
deviceName: iPhone 15
|
|
31
|
+
automationName: XCUITest
|
|
32
|
+
app: RaiderTestApp.app
|
|
33
|
+
autoDismissAlerts: true
|
|
34
|
+
|
|
35
|
+
browserstack:
|
|
36
|
+
platformName: iOS
|
|
37
|
+
os_version: '17.5.1'
|
|
38
|
+
deviceName: iPhone 15
|
|
39
|
+
app: <%= ENV['APP_URL'] %>
|
|
40
|
+
browserstack.user: <%= ENV['BROWSERSTACK_USER'] %>
|
|
41
|
+
browserstack.key: <%= ENV['BROWSERSTACK_KEY'] %>
|
|
42
|
+
project: 'RaiderTestApp'
|
|
43
|
+
name: 'RaiderTestApp-IOS'
|
|
44
|
+
<% elsif android? %>platformName: Android
|
|
45
|
+
appium:options:
|
|
46
|
+
url: http://localhost:4723/wd/hub
|
|
47
|
+
platformVersion: '14'
|
|
48
|
+
automationName: UiAutomator2
|
|
49
|
+
deviceName: Pixel 8 API 34
|
|
50
|
+
app: app-release.apk
|
|
51
|
+
|
|
52
|
+
browserstack:
|
|
53
|
+
platformName: Android
|
|
54
|
+
os_version: '9.0'
|
|
55
|
+
deviceName: Google Pixel 3
|
|
56
|
+
app: app: <%= ENV['APP_URL'] %>
|
|
57
|
+
browserstack.user: <%= ENV['BROWSERSTACK_USER'] %>
|
|
58
|
+
browserstack.key: <%= ENV['BROWSERSTACK_KEY'] %>
|
|
59
|
+
project: 'RaiderTestApp'
|
|
60
|
+
name: 'RaiderTestApp-Android'
|
|
7
61
|
<% end %>
|
|
@@ -6,15 +6,15 @@ class Home < Page
|
|
|
6
6
|
|
|
7
7
|
# Actions
|
|
8
8
|
|
|
9
|
-
def
|
|
10
|
-
driver.wait {
|
|
9
|
+
def go_to_product_detail
|
|
10
|
+
driver.wait { first_product }.click
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
15
|
# Elements
|
|
16
16
|
|
|
17
|
-
def
|
|
18
|
-
<%=
|
|
17
|
+
def first_product
|
|
18
|
+
<%= partial('home_page_selector') -%>
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -1,5 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../abstract/page'
|
|
4
|
+
|
|
5
|
+
class Login < Page
|
|
6
|
+
def url(_page)
|
|
7
|
+
'index.php?rt=account/login'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Actions
|
|
11
|
+
|
|
12
|
+
<%- if capybara? -%>
|
|
13
|
+
def login(username, password)
|
|
14
|
+
fill_in 'loginFrm_loginname', with: username
|
|
15
|
+
fill_in 'loginFrm_password', with: password
|
|
16
|
+
click_button 'Login'
|
|
17
|
+
end
|
|
18
|
+
<%- elsif selenium_based? -%>
|
|
19
|
+
def login(username, password)
|
|
20
|
+
username_field.send_keys username
|
|
21
|
+
password_field.send_keys password
|
|
22
|
+
login_button.click
|
|
23
|
+
end
|
|
24
|
+
alias log_as login
|
|
25
|
+
<%- else -%>
|
|
26
|
+
def login(username, password)
|
|
27
|
+
username_field.set username
|
|
28
|
+
password_field.set password
|
|
29
|
+
login_button.click
|
|
30
|
+
end
|
|
31
|
+
<%- end -%>
|
|
32
|
+
<%- unless capybara? -%>
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# Elements
|
|
37
|
+
|
|
38
|
+
def username_field
|
|
1
39
|
<%- if selenium_based? -%>
|
|
2
|
-
|
|
3
|
-
<%-
|
|
4
|
-
|
|
5
|
-
<%- end -%>
|
|
40
|
+
driver.find_element(id: 'loginFrm_loginname')
|
|
41
|
+
<%- else -%>
|
|
42
|
+
browser.text_field(id: 'loginFrm_loginname')
|
|
43
|
+
<%- end -%>
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def password_field
|
|
47
|
+
<%- if selenium_based? -%>
|
|
48
|
+
driver.find_element(id: 'loginFrm_password')
|
|
49
|
+
<%- else -%>
|
|
50
|
+
browser.text_field(id: 'loginFrm_password')
|
|
51
|
+
<%- end -%>
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def login_button
|
|
55
|
+
<%- if selenium_based? -%>
|
|
56
|
+
driver.find_element(xpath: "//button[@title='Login']")
|
|
57
|
+
<%- else -%>
|
|
58
|
+
browser.button(xpath: "//button[@title='Login']")
|
|
59
|
+
<%- end -%>
|
|
60
|
+
end
|
|
61
|
+
<%- end -%>
|
|
62
|
+
end
|
|
@@ -6,25 +6,31 @@ class Page
|
|
|
6
6
|
<%- if cross_platform? -%>
|
|
7
7
|
include AppiumHelper
|
|
8
8
|
<%- end -%>
|
|
9
|
-
<%=-
|
|
10
|
-
<%=-
|
|
11
|
-
<%=-
|
|
9
|
+
<%=- partial('initialize_selector', trim: false) -%>
|
|
10
|
+
<%=- partial('visit_method', trim: false) -%>
|
|
11
|
+
<%=- partial('url_methods', trim: false) -%>
|
|
12
12
|
|
|
13
13
|
def to_s
|
|
14
14
|
self.class.to_s.sub('Page', ' Page')
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
<%- if
|
|
17
|
+
<%- if capybara? -%>
|
|
18
18
|
# Components
|
|
19
19
|
|
|
20
20
|
def header
|
|
21
|
-
Header.new(
|
|
21
|
+
Header.new(find('.welcome-msg'))
|
|
22
22
|
end
|
|
23
|
-
<%- elsif
|
|
23
|
+
<%- elsif selenium_based? -%>
|
|
24
24
|
# Components
|
|
25
25
|
|
|
26
26
|
def header
|
|
27
|
-
Header.new(
|
|
27
|
+
Header.new(driver.find_element(css: '.welcome-msg'))
|
|
28
|
+
end
|
|
29
|
+
<%- elsif watir? -%>
|
|
30
|
+
# Components
|
|
31
|
+
|
|
32
|
+
def header
|
|
33
|
+
Header.new(browser.element(css: '.welcome-msg'))
|
|
28
34
|
end
|
|
29
35
|
<%- end -%>
|
|
30
36
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<%- if ios? -%>
|
|
2
|
-
driver.find_element(
|
|
2
|
+
driver.find_element(accessibility_id: 'product-item-1')
|
|
3
3
|
<%- elsif android? -%>
|
|
4
|
-
driver.find_element(
|
|
4
|
+
driver.find_element(accessibility_id: 'product-item-1')
|
|
5
5
|
<%- else -%>
|
|
6
|
-
element(ios: {
|
|
7
|
-
android: {
|
|
6
|
+
element(ios: { accessibility_id: 'product-item-1' },
|
|
7
|
+
android: { accessibility_id: 'product-item-1' })
|
|
8
8
|
<%- end -%>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<%- if ios? -%>
|
|
2
|
-
driver.find_element(accessibility_id: '
|
|
2
|
+
driver.find_element(accessibility_id: 'add-to-cart-button')
|
|
3
3
|
<%- elsif android? -%>
|
|
4
|
-
driver.find_element(
|
|
4
|
+
driver.find_element(accessibility_id: 'add-to-cart-button')
|
|
5
5
|
<%- else -%>
|
|
6
|
-
element(ios: { accessibility_id: '
|
|
7
|
-
android: {
|
|
6
|
+
element(ios: { accessibility_id: 'add-to-cart-button' },
|
|
7
|
+
android: { accessibility_id: 'add-to-cart-button' })
|
|
8
8
|
<%- end -%>
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
<% if web? %>
|
|
2
|
+
<% if capybara? %>
|
|
3
|
+
def visit_page(*page)
|
|
4
|
+
Capybara.visit full_url(page.first)
|
|
5
|
+
end
|
|
6
|
+
<% elsif selenium_based? %>
|
|
7
|
+
def visit(*page)
|
|
8
|
+
@driver.navigate.to full_url(page.first)
|
|
9
|
+
end
|
|
10
|
+
<% else %>
|
|
2
11
|
def visit(*page)
|
|
3
|
-
|
|
12
|
+
@browser.goto full_url(page.first)
|
|
4
13
|
end
|
|
14
|
+
<% end %>
|
|
5
15
|
<% end %>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
<%- if
|
|
2
|
-
<%=
|
|
1
|
+
<%- if capybara? -%>
|
|
2
|
+
<%= partial('capybara_env') -%>
|
|
3
|
+
<%- elsif selenium_based? -%>
|
|
4
|
+
<%= partial('selenium_env') -%>
|
|
3
5
|
<%- elsif mobile? -%>
|
|
4
|
-
<%=
|
|
6
|
+
<%= partial('appium_env') -%>
|
|
5
7
|
<%- else -%>
|
|
6
|
-
<%=
|
|
8
|
+
<%= partial('watir_env') -%>
|
|
7
9
|
<%- end -%>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rspec'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require_relative '../../helpers/allure_helper'
|
|
6
|
+
require_relative '../../helpers/capybara_helper'
|
|
7
|
+
|
|
8
|
+
CapybaraHelper.configure
|
|
9
|
+
|
|
10
|
+
Before do
|
|
11
|
+
Capybara.current_session.driver.browser.manage.window.maximize
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
After do |scenario|
|
|
15
|
+
Dir.mktmpdir do |temp_folder|
|
|
16
|
+
screenshot = Capybara.page.save_screenshot("#{temp_folder}/#{scenario.name}.png")
|
|
17
|
+
AllureHelper.add_screenshot(scenario.name, screenshot)
|
|
18
|
+
end
|
|
19
|
+
Capybara.reset_sessions!
|
|
20
|
+
end
|
|
@@ -11,10 +11,10 @@ Given("I'm an anonymous user on the home page") do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
When('I select one of the products') do
|
|
14
|
-
@home_page.
|
|
14
|
+
@home_page.go_to_product_detail
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
Then("I'm redirected to the product details page") do
|
|
18
18
|
pdp_page = Pdp.new(driver)
|
|
19
|
-
expect(pdp_page.add_to_cart_text).to eq 'Add
|
|
19
|
+
expect(pdp_page.add_to_cart_text).to eq 'Add to Cart'
|
|
20
20
|
end
|
|
@@ -5,8 +5,8 @@ require_relative '../../page_objects/pages/login'
|
|
|
5
5
|
|
|
6
6
|
Given("I'm a {user} on the login page") do |user|
|
|
7
7
|
@user = user
|
|
8
|
-
@login_page = Login.new
|
|
9
|
-
@login_page
|
|
8
|
+
@login_page = <% if capybara? %>Login.new<% elsif watir? %>Login.new(browser)<% else %>Login.new(driver)<% end %>
|
|
9
|
+
@login_page.<% if capybara? %>visit_page<% else %>visit<% end %>
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
When('I login with my credentials') do
|
|
@@ -20,10 +20,11 @@ Then('the page should be axe clean') do
|
|
|
20
20
|
end
|
|
21
21
|
<%- else -%>
|
|
22
22
|
Then("I'm logged in") do
|
|
23
|
-
account_page = Account.new
|
|
23
|
+
account_page = <% if capybara? %>Account.new<% elsif watir? %>Account.new(browser)<% else %>Account.new(driver)<% end %>
|
|
24
24
|
<%- if visual? -%>
|
|
25
25
|
check_page account_page
|
|
26
26
|
<%- else -%>
|
|
27
|
+
account_page.<% if capybara? %>visit_page<% else %>visit<% end %>
|
|
27
28
|
expect(account_page.header.customer_name).to eq "Welcome back #{@user['name']}"
|
|
28
29
|
<%- end -%>
|
|
29
30
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%- if web? -%>
|
|
2
|
-
<%=
|
|
2
|
+
<%= partial('web_steps', strip: true) -%>
|
|
3
3
|
<%- else -%>
|
|
4
|
-
<%=
|
|
4
|
+
<%= partial('mobile_steps', strip: true) -%>
|
|
5
5
|
<%- end -%>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
<%- if
|
|
2
|
-
<%=-
|
|
1
|
+
<%- if capybara? -%>
|
|
2
|
+
<%=- partial('capybara_world', strip: true) -%>
|
|
3
|
+
<%- elsif watir? -%>
|
|
4
|
+
<%=- partial('watir_world', strip: true) -%>
|
|
3
5
|
<%- else -%>
|
|
4
|
-
<%=-
|
|
6
|
+
<%=- partial('driver_world', strip: true) -%>
|
|
5
7
|
<%- end -%>
|
data/lib/generators/generator.rb
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'thor'
|
|
4
|
+
require_relative 'template_renderer'
|
|
4
5
|
|
|
6
|
+
# :reek:TooManyMethods { enabled: false }
|
|
5
7
|
class Generator < Thor::Group
|
|
6
8
|
include Thor::Actions
|
|
9
|
+
include TemplateRenderer
|
|
7
10
|
|
|
8
11
|
argument :automation
|
|
9
12
|
argument :framework
|
|
@@ -12,7 +15,8 @@ class Generator < Thor::Group
|
|
|
12
15
|
def self.source_paths
|
|
13
16
|
base_path = File.dirname(__FILE__)
|
|
14
17
|
%W[#{base_path}/automation/templates #{base_path}/cucumber/templates
|
|
15
|
-
#{base_path}/rspec/templates #{base_path}/
|
|
18
|
+
#{base_path}/rspec/templates #{base_path}/minitest/templates
|
|
19
|
+
#{base_path}/templates #{base_path}/infrastructure/templates ]
|
|
16
20
|
end
|
|
17
21
|
|
|
18
22
|
def args
|
|
@@ -48,10 +52,18 @@ class Generator < Thor::Group
|
|
|
48
52
|
args.include?('rspec')
|
|
49
53
|
end
|
|
50
54
|
|
|
55
|
+
def minitest?
|
|
56
|
+
args.include?('minitest')
|
|
57
|
+
end
|
|
58
|
+
|
|
51
59
|
def selenium?
|
|
52
60
|
args.include?('selenium')
|
|
53
61
|
end
|
|
54
62
|
|
|
63
|
+
def capybara?
|
|
64
|
+
args.include?('capybara')
|
|
65
|
+
end
|
|
66
|
+
|
|
55
67
|
def visual?
|
|
56
68
|
args.include?('applitools')
|
|
57
69
|
end
|
|
@@ -61,7 +73,7 @@ class Generator < Thor::Group
|
|
|
61
73
|
end
|
|
62
74
|
|
|
63
75
|
def web?
|
|
64
|
-
(args &
|
|
76
|
+
(args & %w[selenium watir axe applitools capybara]).count.positive?
|
|
65
77
|
end
|
|
66
78
|
|
|
67
79
|
def axe?
|
|
@@ -6,12 +6,15 @@ class HelpersGenerator < Generator
|
|
|
6
6
|
def generate_helpers
|
|
7
7
|
generate_browser_helper
|
|
8
8
|
generate_driver_helper
|
|
9
|
+
generate_capybara_helper
|
|
9
10
|
generate_appium_helper
|
|
10
11
|
generate_allure_helper
|
|
11
12
|
|
|
12
13
|
if visual?
|
|
13
14
|
generate_visual_helper
|
|
14
15
|
generate_visual_spec_helper
|
|
16
|
+
elsif minitest?
|
|
17
|
+
generate_test_helper
|
|
15
18
|
else
|
|
16
19
|
generate_spec_helper
|
|
17
20
|
end
|
|
@@ -24,29 +27,39 @@ class HelpersGenerator < Generator
|
|
|
24
27
|
end
|
|
25
28
|
|
|
26
29
|
def generate_browser_helper
|
|
27
|
-
return if selenium_based? || mobile?
|
|
30
|
+
return if selenium_based? || mobile? || capybara?
|
|
28
31
|
|
|
29
32
|
template('helpers/browser_helper.tt', "#{name}/helpers/browser_helper.rb")
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
def generate_spec_helper
|
|
33
|
-
return if cucumber?
|
|
36
|
+
return if cucumber? || minitest?
|
|
34
37
|
|
|
35
38
|
template('helpers/spec_helper.tt', "#{name}/helpers/spec_helper.rb")
|
|
36
39
|
end
|
|
37
40
|
|
|
38
41
|
def generate_driver_helper
|
|
39
|
-
return if watir?
|
|
42
|
+
return if watir? || capybara?
|
|
40
43
|
|
|
41
44
|
template('helpers/driver_helper.tt', "#{name}/helpers/driver_helper.rb")
|
|
42
45
|
end
|
|
43
46
|
|
|
47
|
+
def generate_capybara_helper
|
|
48
|
+
return unless capybara?
|
|
49
|
+
|
|
50
|
+
template('helpers/capybara_helper.tt', "#{name}/helpers/capybara_helper.rb")
|
|
51
|
+
end
|
|
52
|
+
|
|
44
53
|
def generate_appium_helper
|
|
45
54
|
return unless cross_platform?
|
|
46
55
|
|
|
47
56
|
template('helpers/appium_helper.tt', "#{name}/helpers/appium_helper.rb")
|
|
48
57
|
end
|
|
49
58
|
|
|
59
|
+
def generate_test_helper
|
|
60
|
+
template('helpers/test_helper.tt', "#{name}/helpers/test_helper.rb")
|
|
61
|
+
end
|
|
62
|
+
|
|
50
63
|
def generate_visual_helper
|
|
51
64
|
template('helpers/visual_helper.tt', "#{name}/helpers/visual_helper.rb")
|
|
52
65
|
end
|
|
@@ -8,4 +8,10 @@ class GithubGenerator < Generator
|
|
|
8
8
|
|
|
9
9
|
template('github.tt', "#{name}/.github/workflows/test_pipeline.yml")
|
|
10
10
|
end
|
|
11
|
+
|
|
12
|
+
def generate_appium_pipeline
|
|
13
|
+
return unless mobile?
|
|
14
|
+
|
|
15
|
+
template('github_appium.tt', "#{name}/.github/workflows/appium_pipeline.yml")
|
|
16
|
+
end
|
|
11
17
|
end
|
|
@@ -16,23 +16,27 @@ jobs:
|
|
|
16
16
|
runs-on: ubuntu-latest
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
19
22
|
- name: Set up Ruby
|
|
20
23
|
uses: ruby/setup-ruby@v1
|
|
21
24
|
with:
|
|
22
25
|
ruby-version: 3.4.0
|
|
23
26
|
bundler-cache: true
|
|
24
27
|
|
|
25
|
-
- name:
|
|
26
|
-
uses: actions/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
run: bundle install
|
|
28
|
+
- name: Set up Chrome
|
|
29
|
+
uses: browser-actions/setup-chrome@v1
|
|
30
|
+
with:
|
|
31
|
+
chrome-version: stable
|
|
30
32
|
|
|
31
33
|
- name: Create allure-results folder
|
|
32
34
|
run: mkdir -p allure-results
|
|
33
35
|
|
|
34
|
-
- name:
|
|
35
|
-
run: <%- if framework == 'cucumber' -%>cucumber features --format pretty <%- else -%>bundle exec rspec spec --format documentation<%- end
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: <%- if framework == 'cucumber' -%>bundle exec cucumber features --format pretty<%- elsif minitest? -%>bundle exec ruby -Itest test/test_login_page.rb<%- else -%>bundle exec rspec spec --format documentation<%- end %>
|
|
38
|
+
env:
|
|
39
|
+
HEADLESS: true
|
|
36
40
|
|
|
37
41
|
- name: Get Allure history
|
|
38
42
|
uses: actions/checkout@v2
|