ruby_raider 3.11.0 → 3.12.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/reek.yml +5 -1
- data/.github/workflows/release.yml +2 -1
- data/.github/workflows/system_tests.yml +1 -1
- data/.reek.yml +13 -0
- data/README.md +43 -4
- data/lib/commands/utility_commands.rb +1 -1
- data/lib/generators/automation/automation_generator.rb +15 -10
- data/lib/generators/automation/templates/appium_caps.tt +2 -4
- data/lib/generators/automation/templates/home.tt +1 -2
- data/lib/generators/automation/templates/login.tt +6 -6
- data/lib/generators/automation/templates/page.tt +10 -3
- data/lib/generators/automation/templates/partials/home_page_selector.tt +4 -6
- data/lib/generators/automation/templates/partials/pdp_page_selector.tt +4 -6
- data/lib/generators/automation/templates/pdp.tt +3 -2
- data/lib/generators/cucumber/cucumber_generator.rb +15 -2
- data/lib/generators/cucumber/templates/partials/driver_world.tt +9 -0
- data/lib/generators/cucumber/templates/partials/mobile_steps.tt +1 -1
- data/lib/generators/cucumber/templates/partials/selenium_env.tt +4 -0
- data/lib/generators/cucumber/templates/partials/web_steps.tt +4 -0
- data/lib/generators/generator.rb +15 -4
- data/lib/generators/helper_generator.rb +8 -0
- data/lib/generators/invoke_generators.rb +23 -0
- data/lib/generators/menu_generator.rb +26 -14
- data/lib/generators/rspec/rspec_generator.rb +10 -3
- data/lib/generators/rspec/templates/spec.tt +15 -1
- data/lib/generators/template_renderer/template_error.rb +8 -8
- data/lib/generators/templates/common/partials/mobile_config.tt +1 -0
- data/lib/generators/templates/common/partials/web_config.tt +1 -1
- data/lib/generators/templates/common/read_me.tt +508 -24
- data/lib/generators/templates/helpers/partials/selenium_driver.tt +1 -3
- data/lib/generators/templates/helpers/raider_element.tt +159 -0
- data/lib/generators/templates/helpers/session_state.tt +45 -5
- data/lib/generators/templates/helpers/spec_helper.tt +9 -1
- data/lib/generators/templates/helpers/wait_helper.tt +470 -0
- data/lib/ruby_raider/ffmpeg.rb +7 -7
- data/lib/ruby_raider.rb +2 -0
- data/lib/scaffolding/project_detector.rb +6 -0
- data/lib/scaffolding/scaffolding.rb +4 -0
- data/lib/scaffolding/templates/component.tt +4 -0
- data/lib/scaffolding/templates/page_object.tt +8 -0
- data/lib/version +1 -1
- data/sig/generators/generator.rbs +2 -0
- data/sig/scaffolding/project_detector.rbs +1 -0
- data/sig/scaffolding/scaffolding.rbs +1 -0
- data/spec/commands/raider_commands_spec.rb +24 -0
- data/spec/fixtures/watir_master/cucumber_watir/Readme.md.snapshot +175 -0
- data/spec/fixtures/watir_master/cucumber_watir/features/step_definitions/login_steps.rb.snapshot +24 -0
- data/spec/fixtures/watir_master/cucumber_watir/page_objects/abstract/page.rb.snapshot +39 -0
- data/spec/fixtures/watir_master/cucumber_watir/page_objects/pages/login.rb.snapshot +33 -0
- data/spec/fixtures/watir_master/rspec_watir/Readme.md.snapshot +174 -0
- data/spec/fixtures/watir_master/rspec_watir/page_objects/abstract/page.rb.snapshot +39 -0
- data/spec/fixtures/watir_master/rspec_watir/page_objects/pages/login.rb.snapshot +33 -0
- data/spec/fixtures/watir_master/rspec_watir/spec/login_page_spec.rb.snapshot +49 -0
- data/spec/integration/commands/scaffolding_commands_spec.rb +49 -0
- data/spec/integration/commands/utility_commands_spec.rb +8 -0
- data/spec/integration/content/config_content_spec.rb +44 -0
- data/spec/integration/content/helper_content_spec.rb +79 -0
- data/spec/integration/content/page_content_spec.rb +75 -4
- data/spec/integration/content/readme_content_spec.rb +126 -5
- data/spec/integration/content/syntax_validation_spec.rb +23 -0
- data/spec/integration/content/test_content_spec.rb +57 -0
- data/spec/integration/end_to_end_spec.rb +50 -28
- data/spec/integration/generators/automation_generator_spec.rb +50 -0
- data/spec/integration/generators/common_generator_spec.rb +20 -0
- data/spec/integration/generators/config_features_spec.rb +2 -2
- data/spec/integration/generators/cucumber_generator_spec.rb +36 -0
- data/spec/integration/generators/helpers_generator_spec.rb +38 -0
- data/spec/integration/generators/invoke_generators_spec.rb +70 -0
- data/spec/integration/generators/rspec_generator_spec.rb +20 -0
- data/spec/integration/helpers/session_state_spec.rb +46 -0
- data/spec/integration/helpers/wait_helper_mobile_spec.rb +281 -0
- data/spec/integration/helpers/wait_helper_spec.rb +496 -0
- data/spec/integration/helpers/wait_helper_support.rb +183 -0
- data/spec/integration/settings_helper.rb +4 -1
- data/spec/integration/spec_helper.rb +2 -2
- data/spec/menus/menu_generator_spec.rb +64 -2
- data/spec/scaffolding/scaffold_project_detector_spec.rb +12 -0
- metadata +15 -2
|
@@ -31,6 +31,7 @@ class MenuGenerator
|
|
|
31
31
|
framework: options[:framework],
|
|
32
32
|
accessibility: options[:accessibility],
|
|
33
33
|
ci: options[:ci],
|
|
34
|
+
examples: options[:examples],
|
|
34
35
|
name: @name
|
|
35
36
|
}
|
|
36
37
|
generate_framework(structure)
|
|
@@ -70,32 +71,43 @@ class MenuGenerator
|
|
|
70
71
|
|
|
71
72
|
def select_test_framework(automation)
|
|
72
73
|
prompt.select('Please select your test framework') do |menu|
|
|
73
|
-
menu.choice :Cucumber, -> {
|
|
74
|
-
menu.choice :Rspec, -> {
|
|
74
|
+
menu.choice :Cucumber, -> { select_examples('Cucumber', automation) }
|
|
75
|
+
menu.choice :Rspec, -> { select_examples('Rspec', automation) }
|
|
75
76
|
menu.choice :Quit, -> { exit }
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
def select_examples(framework, automation_type)
|
|
81
|
+
prompt.select('Do you want example tests?') do |menu|
|
|
82
|
+
menu.choice :Yes, -> { select_accessibility(framework, automation_type, examples: true) }
|
|
83
|
+
menu.choice :No, -> { select_accessibility(framework, automation_type, examples: false) }
|
|
84
|
+
menu.choice :Quit, -> { exit }
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
FrameworkOptions = Struct.new(:automation, :framework, :accessibility, :ci, :examples)
|
|
80
89
|
|
|
81
90
|
def create_framework_options(params)
|
|
82
|
-
FrameworkOptions.new(params[:automation], params[:framework], params[:accessibility], params[:ci]
|
|
91
|
+
FrameworkOptions.new(params[:automation], params[:framework], params[:accessibility], params[:ci],
|
|
92
|
+
params[:examples])
|
|
83
93
|
end
|
|
84
94
|
|
|
85
|
-
def select_accessibility(framework, automation_type)
|
|
86
|
-
return create_framework(framework, automation_type) if mobile_automation?(automation_type)
|
|
95
|
+
def select_accessibility(framework, automation_type, examples: true)
|
|
96
|
+
return create_framework(framework, automation_type, examples:) if mobile_automation?(automation_type)
|
|
87
97
|
|
|
88
98
|
prompt.select('Add accessibility testing (axe)?') do |menu|
|
|
89
|
-
menu.choice :Yes, -> { select_ci(framework, automation_type, accessibility: true) }
|
|
90
|
-
menu.choice :No, -> { select_ci(framework, automation_type, accessibility: false) }
|
|
99
|
+
menu.choice :Yes, -> { select_ci(framework, automation_type, accessibility: true, examples:) }
|
|
100
|
+
menu.choice :No, -> { select_ci(framework, automation_type, accessibility: false, examples:) }
|
|
91
101
|
menu.choice :Quit, -> { exit }
|
|
92
102
|
end
|
|
93
103
|
end
|
|
94
104
|
|
|
95
|
-
def select_ci(framework, automation_type, accessibility:)
|
|
105
|
+
def select_ci(framework, automation_type, accessibility:, examples: true)
|
|
96
106
|
prompt.select('Which CI provider?') do |menu|
|
|
97
|
-
menu.choice 'GitHub Actions', -> { create_framework(framework, automation_type, accessibility:) }
|
|
98
|
-
menu.choice 'Azure Pipelines',
|
|
107
|
+
menu.choice 'GitHub Actions', -> { create_framework(framework, automation_type, accessibility:, examples:) }
|
|
108
|
+
menu.choice 'Azure Pipelines', lambda {
|
|
109
|
+
create_framework(framework, automation_type, accessibility:, ci_provider: 'azure', examples:)
|
|
110
|
+
}
|
|
99
111
|
menu.choice :Quit, -> { exit }
|
|
100
112
|
end
|
|
101
113
|
end
|
|
@@ -104,16 +116,17 @@ class MenuGenerator
|
|
|
104
116
|
%w[ios android cross_platform].include?(automation_type)
|
|
105
117
|
end
|
|
106
118
|
|
|
107
|
-
def create_framework(framework, automation_type, accessibility: false, ci_provider: nil)
|
|
119
|
+
def create_framework(framework, automation_type, accessibility: false, ci_provider: nil, examples: true)
|
|
108
120
|
options = create_framework_options(automation: automation_type,
|
|
109
121
|
framework: framework.downcase,
|
|
110
|
-
accessibility:, ci: ci_provider)
|
|
122
|
+
accessibility:, ci: ci_provider, examples:)
|
|
111
123
|
|
|
112
124
|
puts 'Chosen Options:'
|
|
113
125
|
puts " Automation Type: #{options[:automation]}"
|
|
114
126
|
puts " Framework: #{options[:framework]}"
|
|
115
127
|
puts ' Accessibility: enabled' if options[:accessibility]
|
|
116
128
|
puts ' CI: Azure Pipelines' if options[:ci] == 'azure'
|
|
129
|
+
puts ' Example tests: none' unless options[:examples]
|
|
117
130
|
|
|
118
131
|
set_up_framework(options)
|
|
119
132
|
prompt.say("You have chosen to use #{framework} with #{automation_type}")
|
|
@@ -135,6 +148,5 @@ class MenuGenerator
|
|
|
135
148
|
def automation_options(menu)
|
|
136
149
|
menu.choice :Selenium, -> { choose_test_framework('selenium') }
|
|
137
150
|
menu.choice :Appium, -> { choose_test_framework('appium') }
|
|
138
|
-
menu.choice :Watir, -> { choose_test_framework('watir') }
|
|
139
151
|
end
|
|
140
152
|
end
|
|
@@ -3,20 +3,27 @@
|
|
|
3
3
|
require_relative '../generator'
|
|
4
4
|
|
|
5
5
|
class RspecGenerator < Generator
|
|
6
|
+
# A skeleton has an empty spec/ (the generated CI runs `rspec spec`), and no example specs
|
|
7
|
+
def generate_empty_spec_folder
|
|
8
|
+
return if examples?
|
|
9
|
+
|
|
10
|
+
create_file("#{name}/spec/.keep", '')
|
|
11
|
+
end
|
|
12
|
+
|
|
6
13
|
def generate_login_spec
|
|
7
|
-
return unless web?
|
|
14
|
+
return unless web? && examples?
|
|
8
15
|
|
|
9
16
|
template('spec.tt', "#{name}/spec/login_page_spec.rb")
|
|
10
17
|
end
|
|
11
18
|
|
|
12
19
|
def generate_pdp_spec
|
|
13
|
-
return unless mobile?
|
|
20
|
+
return unless mobile? && examples?
|
|
14
21
|
|
|
15
22
|
template('spec.tt', "#{name}/spec/pdp_page_spec.rb")
|
|
16
23
|
end
|
|
17
24
|
|
|
18
25
|
def generate_accessibility_spec
|
|
19
|
-
return unless axe_addon? && web?
|
|
26
|
+
return unless axe_addon? && web? && examples?
|
|
20
27
|
|
|
21
28
|
template('accessibility_spec.tt', "#{name}/spec/accessibility_spec.rb")
|
|
22
29
|
end
|
|
@@ -8,8 +8,10 @@ require_relative '../page_objects/pages/login'
|
|
|
8
8
|
|
|
9
9
|
# rubocop:disable RSpec/MultipleDescribes
|
|
10
10
|
describe 'Login' do
|
|
11
|
+
<%- if watir? -%>
|
|
11
12
|
subject(:header) { account_page.header.customer_name }
|
|
12
13
|
|
|
14
|
+
<%- end -%>
|
|
13
15
|
let(:user) { ModelFactory.for('users')['registered user'] }
|
|
14
16
|
let(:login_page) { <% if watir? -%>Login.new(browser)<% else -%>Login.new(driver)<% end -%> }
|
|
15
17
|
let(:account_page) { <% if watir? -%>Account.new(browser)<% else -%>Account.new(driver)<% end -%> }
|
|
@@ -24,7 +26,11 @@ describe 'Login' do
|
|
|
24
26
|
|
|
25
27
|
it 'can successfully log in' do
|
|
26
28
|
account_page.visit
|
|
29
|
+
<%- if watir? -%>
|
|
27
30
|
expect(header).to eq "Welcome back #{user['name']}"
|
|
31
|
+
<%- else -%>
|
|
32
|
+
eventually { expect(account_page.header.customer_name).to eq "Welcome back #{user['name']}" }
|
|
33
|
+
<%- end -%>
|
|
28
34
|
end
|
|
29
35
|
end
|
|
30
36
|
|
|
@@ -33,7 +39,11 @@ describe 'Login' do
|
|
|
33
39
|
|
|
34
40
|
it 'cannot log in' do
|
|
35
41
|
login_page.visit
|
|
42
|
+
<%- if watir? -%>
|
|
36
43
|
expect(header).to eq 'Login or register'
|
|
44
|
+
<%- else -%>
|
|
45
|
+
eventually { expect(account_page.header.customer_name).to eq 'Login or register' }
|
|
46
|
+
<%- end -%>
|
|
37
47
|
end
|
|
38
48
|
end
|
|
39
49
|
end
|
|
@@ -44,7 +54,11 @@ describe 'Account', :logged_in do
|
|
|
44
54
|
|
|
45
55
|
it 'opens the account page with the saved login' do
|
|
46
56
|
account_page.visit
|
|
57
|
+
<%- if watir? -%>
|
|
47
58
|
expect(account_page.header.customer_name).to eq "Welcome back #{user['name']}"
|
|
59
|
+
<%- else -%>
|
|
60
|
+
eventually { expect(account_page.header.customer_name).to eq "Welcome back #{user['name']}" }
|
|
61
|
+
<%- end -%>
|
|
48
62
|
end
|
|
49
63
|
end
|
|
50
64
|
# rubocop:enable RSpec/MultipleDescribes
|
|
@@ -64,7 +78,7 @@ class PdpSpec
|
|
|
64
78
|
|
|
65
79
|
it 'shows add to cart button' do
|
|
66
80
|
home_page.go_to_product_detail
|
|
67
|
-
expect(pdp_page.add_to_cart_text).to eq 'Add to Cart'
|
|
81
|
+
eventually { expect(pdp_page.add_to_cart_text).to eq 'Add to Cart' }
|
|
68
82
|
end
|
|
69
83
|
end
|
|
70
84
|
end
|
|
@@ -16,11 +16,11 @@ module TemplateRenderer
|
|
|
16
16
|
# Raised when a partial template cannot be found
|
|
17
17
|
class TemplateNotFoundError < TemplateError
|
|
18
18
|
def to_s
|
|
19
|
-
message_parts = ["Partial '#{
|
|
19
|
+
message_parts = ["Partial '#{partial_name}' not found."]
|
|
20
20
|
|
|
21
|
-
if
|
|
21
|
+
if searched_paths.any?
|
|
22
22
|
message_parts << "\nSearched in:"
|
|
23
|
-
message_parts.concat(
|
|
23
|
+
message_parts.concat(searched_paths.map { |path| " - #{path}" })
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
message_parts.join("\n")
|
|
@@ -34,13 +34,13 @@ module TemplateRenderer
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def to_s
|
|
37
|
-
message_parts = ["Error rendering partial '#{
|
|
37
|
+
message_parts = ["Error rendering partial '#{partial_name}': #{super()}"]
|
|
38
38
|
|
|
39
|
-
if
|
|
40
|
-
message_parts << "\nOriginal error: #{
|
|
41
|
-
if
|
|
39
|
+
if original_error
|
|
40
|
+
message_parts << "\nOriginal error: #{original_error.class}: #{original_error.message}"
|
|
41
|
+
if original_error.backtrace
|
|
42
42
|
message_parts << "\nBacktrace:"
|
|
43
|
-
message_parts.concat(
|
|
43
|
+
message_parts.concat(original_error.backtrace.first(5).map { |line| " #{line}" })
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
browser: chrome
|
|
2
2
|
url: 'https://raider-test-site.onrender.com/'
|
|
3
|
-
timeout: 10 # seconds — used for implicit waits and max wait time
|
|
3
|
+
timeout: 10 # <%= wait_helper? ? 'seconds that actions and eventually wait before failing' : 'seconds — used for implicit waits and max wait time' %>
|
|
4
4
|
viewport:
|
|
5
5
|
width: 1920
|
|
6
6
|
height: 1080
|