ruby_raider 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/auto_assign-issues.yml +8 -0
  3. data/.github/workflows/rspec.yml +2 -0
  4. data/.reek.yml +5 -1
  5. data/Rakefile +6 -0
  6. data/lib/commands/open_ai_commands.rb +9 -7
  7. data/lib/commands/scaffolding_commands.rb +35 -24
  8. data/lib/commands/utility_commands.rb +19 -7
  9. data/lib/desktop/components/base_component.rb +18 -0
  10. data/lib/desktop/components/runner_components.rb +185 -0
  11. data/lib/desktop/screens/runner_screen.rb +20 -0
  12. data/lib/generators/automation/automation_examples_generator.rb +14 -11
  13. data/lib/generators/automation/automation_generator.rb +4 -4
  14. data/lib/generators/automation/templates/partials/selenium_login.tt +5 -5
  15. data/lib/generators/automation/templates/partials/url_methods.tt +1 -0
  16. data/lib/generators/automation/templates/partials/watir_login.tt +1 -1
  17. data/lib/generators/common_generator.rb +11 -3
  18. data/lib/generators/generator.rb +21 -1
  19. data/lib/generators/helper_generator.rb +21 -18
  20. data/lib/generators/invoke_generators.rb +5 -2
  21. data/lib/generators/menu_generator.rb +38 -19
  22. data/lib/generators/rspec/rspec_examples_generator.rb +14 -2
  23. data/lib/generators/rspec/templates/base_spec.tt +3 -1
  24. data/lib/generators/rspec/templates/data.tt +4 -0
  25. data/lib/generators/rspec/templates/factory.tt +10 -0
  26. data/lib/generators/rspec/templates/spec.tt +11 -7
  27. data/lib/generators/templates/common/gemfile.tt +5 -0
  28. data/lib/generators/templates/common/reek.tt +9 -0
  29. data/lib/generators/templates/common/rubocop.tt +92 -0
  30. data/lib/generators/templates/helpers/driver_helper.tt +2 -2
  31. data/lib/generators/templates/helpers/partials/driver_and_options.tt +3 -1
  32. data/lib/generators/templates/helpers/raider_helper.tt +0 -1
  33. data/lib/open_ai/open_ai.rb +13 -7
  34. data/lib/ruby_raider.rb +9 -0
  35. data/lib/utilities/utilities.rb +6 -18
  36. data/ruby_raider.gemspec +1 -1
  37. data/spec/common_generator_spec.rb +11 -5
  38. data/spec/open_ai_commands_spec.rb +5 -4
  39. data/spec/rspec_generator_spec.rb +12 -0
  40. data/spec/ruby_raider_spec.rb +31 -0
  41. data/spec/spec_helper.rb +4 -12
  42. metadata +11 -4
  43. data/lib/generators/templates/helpers/partials/require_automation.tt +0 -3
  44. data/lib/generators/templates/helpers/selenium_helper.tt +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 343290e25435b54bda41d2a43a13eb23713e4ac1b89d773e1a981e250dce0bda
4
- data.tar.gz: 72610baae56c1f6b22364d1ad5717425f781c987972a59470e831a2c8c627a8c
3
+ metadata.gz: b2cbd602b0c6fa72ff1e5d3b84ddc3c847e5257fceae9781f8165a81bc76d1a3
4
+ data.tar.gz: 6fd1e508cce664cc5320fce27c02fc293239a6f8bd1dc2c3086fd4aa872522cb
5
5
  SHA512:
6
- metadata.gz: 8d2bbcec5a84038878369fb76d31ae8965abcf9300b7aa02957ca0ff2c4244e74c8ecd195dbb7eb053218974bc286b99fac6074baafdb40af021a5e75b56ed3b
7
- data.tar.gz: 987a2a4fe907958384ba1e1ccd110987bbff1cd497577f5f51621fd3ab4bdaffdceff43bbe829ec0c9847fe7fe5ad470047da5a1c9040af29172458248f9cbd4
6
+ metadata.gz: 6c3b23442dc4e9794d250f0b6f55d30d2ab12558ddadb9f2a7df1d3bdb308ace5ef177469ef742c2a862aa4c7ae9f49fe5cf47f701eb448b3d919c63717f0d5d
7
+ data.tar.gz: ab97943342749bed0e721ba435995505c5dc356b9b85a80b666295babac0ddaa95d0bfd03d2889a619ad432f0b09810e71cbe4b63a2762764f4a12da383b02df
@@ -0,0 +1,8 @@
1
+ # If enabled, auto-assigns users when a new issue is created
2
+ # Defaults to true, allows you to install the app globally, and disable on a per-repo basis
3
+ addAssignees: true
4
+
5
+ # The list of users to assign to new issues.
6
+ # If empty or not provided, the repository owner is assigned
7
+ assignees:
8
+ - aguspe
@@ -24,4 +24,6 @@ jobs:
24
24
  run: bundle install
25
25
 
26
26
  - name: Build and test with rspec
27
+ env:
28
+ OPENAI_ACCESS_TOKEN: ${{ secrets.OPENAI_ACCESS_TOKEN }}
27
29
  run: bundle exec rspec spec
data/.reek.yml CHANGED
@@ -6,4 +6,8 @@ detectors:
6
6
  enabled: true
7
7
  exclude:
8
8
  - initialize
9
- max_statements: 10
9
+ max_statements: 10
10
+
11
+ exclude_paths:
12
+ - 'lib/desktop/components/*.rb'
13
+ - 'lib/desktop/screens/*.rb'
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative 'lib/ruby_raider'
4
4
  require_relative 'lib/commands/scaffolding_commands'
5
+ require_relative 'lib/desktop/screens/runner_screen'
5
6
 
6
7
  desc 'Creates a new test project'
7
8
  task :new, [:name] do |_t, args|
@@ -27,3 +28,8 @@ desc 'Download mobile builds'
27
28
  task :builds, [:type] do |_t, args|
28
29
  ScaffoldingCommands.new.invoke(:download_builds, nil, %W[#{args.type}])
29
30
  end
31
+
32
+ desc 'Open the run screen'
33
+ task :runner do
34
+ RunnerScreen.new.launch
35
+ end
@@ -10,16 +10,17 @@ class OpenAiCommands < Thor
10
10
 
11
11
  def make(request, path = nil)
12
12
  path ||= options[:path]
13
- if options[:edit]
13
+ edit_path = options[:edit]
14
+ if edit_path
14
15
  pp 'Editing File...'
15
- OpenAi.edit_file(options[:edit], request)
16
- pp "File #{options[:edit]} edited"
16
+ OpenAi.edit_file(path: edit_path, request: request)
17
+ pp "File #{edit_path} edited"
17
18
  elsif path
18
19
  pp 'Generating File...'
19
- OpenAi.create_file(path, request)
20
+ OpenAi.create_file(path: path, request: request)
20
21
  pp "File created in #{path}"
21
22
  else
22
- puts OpenAi.output(request)
23
+ puts OpenAi.output(request: request)
23
24
  end
24
25
  end
25
26
 
@@ -48,9 +49,10 @@ class OpenAiCommands < Thor
48
49
 
49
50
  def steps(name)
50
51
  path = 'features/step_definitions'
51
- if options[:input]
52
+ input = options[:input]
53
+ if input
52
54
  prompt = options[:prompt] || 'create cucumber steps for the following scenarios in ruby'
53
- content = "#{prompt} #{File.read(options[:input])}"
55
+ content = "#{prompt} #{File.read(input)}"
54
56
  make(content, "#{path}/#{name}_steps.rb")
55
57
  else
56
58
  make(options[:open_ai], "#{path}/#{name}_steps.rb")
@@ -5,6 +5,8 @@ require_relative '../generators/menu_generator'
5
5
  require_relative '../scaffolding/scaffolding'
6
6
  require_relative '../commands/utility_commands'
7
7
 
8
+ # :reek:FeatureEnvy { enabled: false }
9
+ # :reek:UtilityFunction { enabled: false }
8
10
  class ScaffoldingCommands < Thor
9
11
  desc 'page [PAGE_NAME]', 'Creates a new page object'
10
12
  option :path,
@@ -13,12 +15,7 @@ class ScaffoldingCommands < Thor
13
15
  type: :boolean, required: false, desc: 'This will delete the selected page', aliases: '-d'
14
16
 
15
17
  def page(name)
16
- path = options[:path] || load_config_path('page')
17
- if options[:delete]
18
- Scaffolding.new([name, path]).delete_class
19
- else
20
- Scaffolding.new([name, path]).generate_class
21
- end
18
+ handle_scaffolding(name, 'page')
22
19
  end
23
20
 
24
21
  desc 'feature [NAME]', 'Creates a new feature'
@@ -30,12 +27,7 @@ class ScaffoldingCommands < Thor
30
27
  required: false, desc: 'This will delete the selected feature', aliases: '-d'
31
28
 
32
29
  def feature(name)
33
- path = options[:path] || load_config_path('feature')
34
- if options[:delete]
35
- Scaffolding.new([name, path]).delete_feature
36
- else
37
- Scaffolding.new([name, path]).generate_feature
38
- end
30
+ handle_scaffolding(name, 'feature')
39
31
  end
40
32
 
41
33
  desc 'spec [SPEC_NAME]', 'Creates a new spec'
@@ -45,12 +37,7 @@ class ScaffoldingCommands < Thor
45
37
  type: :boolean, required: false, desc: 'This will delete the selected spec', aliases: '-d'
46
38
 
47
39
  def spec(name)
48
- path = options[:path] || load_config_path('spec')
49
- if options[:delete]
50
- Scaffolding.new([name, path]).delete_spec
51
- else
52
- Scaffolding.new([name, path]).generate_spec
53
- end
40
+ handle_scaffolding(name, 'spec')
54
41
  end
55
42
 
56
43
  desc 'helper [HELPER_NAME]', 'Creates a new helper'
@@ -60,12 +47,7 @@ class ScaffoldingCommands < Thor
60
47
  type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d'
61
48
 
62
49
  def helper(name)
63
- path = options[:path] || load_config_path('helper')
64
- if options[:delete]
65
- Scaffolding.new([name, path]).delete_helper
66
- else
67
- Scaffolding.new([name, path]).generate_helper
68
- end
50
+ handle_scaffolding(name, 'helper')
69
51
  end
70
52
 
71
53
  desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
@@ -87,5 +69,34 @@ class ScaffoldingCommands < Thor
87
69
  def load_config_path(type)
88
70
  YAML.load_file('config/config.yml')["#{type}_path"] if Pathname.new('config/config.yml').exist?
89
71
  end
72
+
73
+ def handle_scaffolding(name, type)
74
+ path = options[:path] || load_config_path(type)
75
+ scaffolding = Scaffolding.new([name, path])
76
+
77
+ if options[:delete]
78
+ case type
79
+ when 'page'
80
+ scaffolding.delete_class
81
+ when 'feature'
82
+ scaffolding.delete_feature
83
+ when 'spec'
84
+ scaffolding.delete_spec
85
+ when 'helper'
86
+ scaffolding.delete_helper
87
+ end
88
+ else
89
+ case type
90
+ when 'page'
91
+ scaffolding.generate_class
92
+ when 'feature'
93
+ scaffolding.generate_feature
94
+ when 'spec'
95
+ scaffolding.generate_spec
96
+ when 'helper'
97
+ scaffolding.generate_helper
98
+ end
99
+ end
100
+ end
90
101
  end
91
102
  end
@@ -3,6 +3,8 @@
3
3
  require 'thor'
4
4
  require_relative '../utilities/utilities'
5
5
 
6
+ # :reek:FeatureEnvy { enabled: false }
7
+ # :reek:UtilityFunction { enabled: false }
6
8
  class UtilityCommands < Thor
7
9
  desc 'path [PATH]', 'Sets the default path for scaffolding'
8
10
  option :feature,
@@ -31,7 +33,8 @@ class UtilityCommands < Thor
31
33
 
32
34
  def browser(default_browser = nil)
33
35
  Utilities.browser = default_browser if default_browser
34
- browser_options(options[:opts]) if options[:opts] || options[:delete]
36
+ selected_options = options[:opts]
37
+ browser_options(selected_options) if selected_options || options[:delete]
35
38
  end
36
39
 
37
40
  desc 'browser_options [OPTIONS]', 'Sets the browser options for the project'
@@ -50,10 +53,11 @@ class UtilityCommands < Thor
50
53
  type: :array, required: false, desc: 'The options that your run will run with', aliases: '-o'
51
54
 
52
55
  def raid
56
+ selected_options = options[:opts]
53
57
  if options[:parallel]
54
- Utilities.parallel_run(options[:opts])
58
+ Utilities.parallel_run(selected_options)
55
59
  else
56
- Utilities.run(options[:opts])
60
+ Utilities.run(selected_options)
57
61
  end
58
62
  end
59
63
 
@@ -69,10 +73,18 @@ class UtilityCommands < Thor
69
73
  Utilities.platform = platform
70
74
  end
71
75
 
72
- desc 'builds [BUILD_TYPE]', 'It downloads the example builds for appium projects'
73
- def builds(build_type)
74
- raise 'Please select one of the following build types: android, ios, both' unless %w[android ios both].include?(build_type)
76
+ desc 'build [BUILD_TYPE]', 'It downloads the selected example build for appium projects'
75
77
 
76
- Utilities.download_builds build_type
78
+ def build(build_type)
79
+ raise 'Please select one of the following build types: android, ios' unless %w[android ios].include?(build_type)
80
+
81
+ build_type == 'android' ? Utilities.download_android_build : Utilities.download_ios_build
82
+ end
83
+
84
+ desc 'builds', 'It downloads both builds for appium cross platform projects'
85
+
86
+ def builds
87
+ Utilities.download_android_build
88
+ Utilities.download_ios_build
77
89
  end
78
90
  end
@@ -0,0 +1,18 @@
1
+ require 'glimmer-dsl-libui'
2
+
3
+ class BaseComponent
4
+ include Glimmer
5
+
6
+ def initialize
7
+ super
8
+ if File.directory?('spec')
9
+ @folder = 'spec'
10
+ @framework = 'rspec'
11
+ @extension = '*_spec.rb'
12
+ else
13
+ @folder = 'features'
14
+ @framework = 'cucumber'
15
+ @extension = '*.features'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,185 @@
1
+ require 'open3'
2
+ require 'yaml'
3
+ require_relative 'base_component'
4
+ require_relative '../../scaffolding/scaffolding'
5
+
6
+ class RunnerComponents < BaseComponent
7
+ attr_accessor :contacts
8
+
9
+ CONFIG_ITEM = Struct.new(:attribute, :value)
10
+ CAP = Struct.new(:attribute, :value)
11
+
12
+ def header
13
+ grid do
14
+ stretchy false
15
+
16
+ button('▶') do
17
+ left 0
18
+ on_clicked do
19
+ output = Open3.popen3("#{@framework} #{@tests.selected_item}") do |_stdin, stdout, _stderr|
20
+ stdout.read
21
+ end
22
+ system "#{@framework} #{@tests.selected_item}"
23
+ @results.text = output
24
+ end
25
+ end
26
+ button('■') do
27
+ left 1
28
+ on_clicked do
29
+ pp 'The stop feature will be implemented in a later release'
30
+ end
31
+ end
32
+
33
+ @tests = combobox do
34
+ left 2
35
+ files = Dir.glob(File.join(@folder, @extension))
36
+ multiple_items = files.count.positive? ? files : ['There are no tests please create a new one']
37
+ items multiple_items
38
+ selected_item files.first
39
+ @file = files.count.positive? ? File.open(files.first) : ''
40
+
41
+ on_selected do |items|
42
+ @results.text = ''
43
+ path = items.selected_item
44
+ @file = File.open(path)
45
+ @text_box.text = @file.read
46
+ end
47
+ end
48
+
49
+ button('Open Dashboard') do
50
+ left 3
51
+ halign :end
52
+ on_clicked do
53
+ system 'allure serve allure-reports'
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ def tests_tab
60
+ tab_item('Tests') do
61
+ horizontal_box do
62
+ @text_box = multiline_entry do
63
+ text @file.read
64
+
65
+ on_changed do |e|
66
+ File.write(@tests.selected_item, e.text)
67
+ $stdout.flush # for Windows
68
+ end
69
+ end
70
+
71
+ @results = multiline_entry do
72
+ text ''
73
+ end
74
+ end
75
+ end
76
+ end
77
+
78
+ def config_tab
79
+ tab_item('Configuration') do
80
+ @config_data = load_or_create_config
81
+ @config_items = @config_data.map { |key, value| CONFIG_ITEM.new(key, value) }
82
+ vertical_box do
83
+ refined_table(
84
+ model_array: @config_items,
85
+ table_columns: {
86
+ 'Attribute' => :text,
87
+ 'Value' => { text: { editable: true } }
88
+ },
89
+ table_editable: true,
90
+ per_page: 20
91
+ )
92
+ end
93
+ end
94
+ end
95
+
96
+ def editor_tab
97
+ tab_item('Editor') do
98
+ horizontal_box do
99
+ vertical_box do
100
+ horizontal_box do
101
+ button('Create Test') do
102
+ on_clicked do
103
+ Scaffolding.new([@test_name.text]).generate_spec
104
+ end
105
+ end
106
+ @test_name = entry do
107
+ text 'test_example'
108
+ end
109
+ end
110
+ horizontal_box do
111
+ button('Create Page') do
112
+ on_clicked do
113
+ Scaffolding.new([@page_name.text]).generate_class
114
+ end
115
+ end
116
+ @page_name = entry do
117
+ text 'page_example'
118
+ end
119
+ end
120
+ horizontal_box do
121
+ button('Create Helper') do
122
+ on_clicked do
123
+ Scaffolding.new([@helper_name.text]).generate_helper
124
+ end
125
+ end
126
+ @helper_name = entry do
127
+ text 'helper_example'
128
+ end
129
+ end
130
+ vertical_separator do
131
+ stretchy false
132
+ end
133
+ end
134
+ vertical_box do
135
+ @editable_files = combobox do
136
+ @all_files = load_all_files
137
+ stretchy false
138
+ visible true
139
+ items @all_files
140
+ selected_item @all_files.first
141
+
142
+ on_selected do |items|
143
+ path = items.selected_item
144
+ @edit_file = File.open(path)
145
+ @edit_box.text = @edit_file.read
146
+ end
147
+ end
148
+ @edit_box = multiline_entry do
149
+ text File.read(@all_files.first)
150
+
151
+ on_changed do |e|
152
+ File.write(@editable_files.selected_item, e.text)
153
+ $stdout.flush # for Windows
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
160
+
161
+ private
162
+
163
+ def load_all_files
164
+ test_files = Dir.glob(File.join(@folder, @extension))
165
+ page_object_files = Dir.glob(File.join('page_objects/pages', '*.rb'))
166
+ helper_files = Dir.glob(File.join('helpers', '*.rb'))
167
+ test_files + page_object_files + helper_files
168
+ end
169
+
170
+ def load_or_create_config
171
+ file_paths = {
172
+ config: 'config/config.yml',
173
+ caps: 'config/capabilities.yml',
174
+ opts: 'config/options.yml'
175
+ }
176
+
177
+ loaded_files = file_paths.transform_values do |path|
178
+ File.exist?(path) ? YAML.load_file(path) : {}
179
+ end
180
+
181
+ return { message: 'Create a config file to access your attributes' } if loaded_files.values.all?(&:empty?)
182
+
183
+ loaded_files[:config].merge(loaded_files[:caps]).merge(loaded_files[:opts])
184
+ end
185
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../components/runner_components'
4
+
5
+ class RunnerScreen < RunnerComponents
6
+ def launch
7
+ window('Ruby Raider', 1200, 800) do
8
+ margined true
9
+ vertical_box do
10
+ header
11
+ tab do
12
+ stretchy true
13
+ tests_tab
14
+ editor_tab
15
+ config_tab
16
+ end
17
+ end
18
+ end.show
19
+ end
20
+ end
@@ -3,34 +3,37 @@
3
3
  require_relative '../generator'
4
4
 
5
5
  class AutomationExamplesGenerator < Generator
6
- def generate_login_page
7
- return unless (@_initializer.first & %w[android ios cross_platform]).empty?
6
+ def generate_example_files
7
+ if mobile_platform?
8
+ generate_home_page
9
+ generate_pdp_page
10
+ else
11
+ generate_login_page
12
+ generate_header_component unless visual_selected?
13
+ end
14
+
15
+ generate_app_page if visual_selected?
16
+ end
8
17
 
18
+ private
19
+
20
+ def generate_login_page
9
21
  template('login_page.tt', "#{name}/page_objects/pages/login_page.rb")
10
22
  end
11
23
 
12
24
  def generate_home_page
13
- return if (@_initializer.first & %w[android ios cross_platform]).empty?
14
-
15
25
  template('home_page.tt', "#{name}/page_objects/pages/home_page.rb")
16
26
  end
17
27
 
18
28
  def generate_pdp_page
19
- return if (@_initializer.first & %w[android ios cross_platform]).empty?
20
-
21
29
  template('pdp_page.tt', "#{name}/page_objects/pages/pdp_page.rb")
22
30
  end
23
31
 
24
32
  def generate_header_component
25
- return unless (@_initializer.first & %w[android ios cross_platform]).empty?
26
- return if @_initializer.first.last
27
-
28
33
  template('component.tt', "#{name}/page_objects/components/header_component.rb")
29
34
  end
30
35
 
31
36
  def generate_app_page
32
- return unless @_initializer.first.last
33
-
34
37
  template('app_page.tt', "#{name}/page_objects/pages/app_page.rb")
35
38
  end
36
39
  end
@@ -8,20 +8,20 @@ class AutomationGenerator < Generator
8
8
  end
9
9
 
10
10
  def generate_abstract_component
11
- return unless (@_initializer.first & %w[android ios cross_platform]).empty?
12
- return if @_initializer.first.last
11
+ return if mobile_platform?
12
+ return if visual_selected?
13
13
 
14
14
  template('abstract_component.tt', "#{name}/page_objects/abstract/abstract_component.rb")
15
15
  end
16
16
 
17
17
  def generate_appium_settings
18
- return if (@_initializer.first & %w[android ios cross_platform]).empty?
18
+ return unless mobile_platform?
19
19
 
20
20
  template('appium_caps.tt', "#{name}/config/capabilities.yml")
21
21
  end
22
22
 
23
23
  def generate_visual_options
24
- return unless @_initializer.first.last
24
+ return unless visual_selected?
25
25
 
26
26
  template('visual_options.tt', "#{name}/config/options.yml")
27
27
  end
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../abstract/abstract_page'
2
4
  require_relative '../components/header_component'
3
5
 
4
6
  class LoginPage < AbstractPage
5
- using Raider::SeleniumHelper
6
-
7
7
  def url(_page)
8
8
  'index.php?rt=account/login'
9
9
  end
@@ -13,13 +13,13 @@ class LoginPage < AbstractPage
13
13
  def login(username, password)
14
14
  username_field.send_keys username
15
15
  password_field.send_keys password
16
- login_button.click_when_present
16
+ login_button.click
17
17
  end
18
18
 
19
19
  # Components
20
20
 
21
21
  def header
22
- HeaderComponent.new(@driver.find_element(class: 'menu_text'))
22
+ HeaderComponent.new(driver.find_element(class: 'menu_text'))
23
23
  end
24
24
 
25
25
  private
@@ -37,4 +37,4 @@ class LoginPage < AbstractPage
37
37
  def login_button
38
38
  driver.find_element(xpath: "//button[@title='Login']")
39
39
  end
40
- end
40
+ end
@@ -3,6 +3,7 @@
3
3
  "#{base_url}#{url(*page)}"
4
4
  end
5
5
 
6
+ # :reek:UtilityFunction
6
7
  def base_url
7
8
  YAML.load_file('config/config.yml')['url']
8
9
  end
@@ -18,7 +18,7 @@ class LoginPage < AbstractPage
18
18
  # Components
19
19
 
20
20
  def header
21
- HeaderComponent.new(@browser.element(class: 'menu_text'))
21
+ HeaderComponent.new(browser.element(class: 'menu_text'))
22
22
  end
23
23
 
24
24
  private
@@ -8,7 +8,7 @@ class CommonGenerator < Generator
8
8
  end
9
9
 
10
10
  def generate_config_file
11
- return unless (@_initializer.first & %w[android ios]).empty?
11
+ return if mobile_platform?
12
12
 
13
13
  template('common/config.tt', "#{name}/config/config.yml")
14
14
  end
@@ -21,11 +21,19 @@ class CommonGenerator < Generator
21
21
  template('common/gemfile.tt', "#{name}/Gemfile")
22
22
  end
23
23
 
24
+ def generate_reek_file
25
+ template('common/reek.tt', "#{name}/.reek.yml")
26
+ end
27
+
28
+ def generate_rubocop_file
29
+ template('common/rubocop.tt', "#{name}/.rubocop.yml")
30
+ end
31
+
24
32
  def create_allure_folder
25
- empty_directory "#{name}/allure-results" unless @_initializer.first.last
33
+ empty_directory "#{name}/allure-results" unless visual_selected?
26
34
  end
27
35
 
28
36
  def create_screenshots_folder
29
- empty_directory "#{name}/allure-results/screenshots" unless @_initializer.first.last
37
+ empty_directory "#{name}/allure-results/screenshots" unless visual_selected?
30
38
  end
31
39
  end
@@ -11,6 +11,26 @@ class Generator < Thor::Group
11
11
  argument :visual_automation, optional: true
12
12
 
13
13
  def self.source_paths
14
- %W[#{File.dirname(__FILE__)}/automation/templates #{File.dirname(__FILE__)}/cucumber/templates #{File.dirname(__FILE__)}/rspec/templates #{File.dirname(__FILE__)}/templates]
14
+ base_path = File.dirname(__FILE__)
15
+ %W[#{base_path}/automation/templates #{base_path}/cucumber/templates #{base_path}/rspec/templates #{base_path}/templates]
15
16
  end
17
+
18
+ def args
19
+ initializer.first
20
+ end
21
+
22
+ def visual_selected?
23
+ initializer.first.last
24
+ end
25
+
26
+ def mobile_platform?
27
+ (args & %w[android ios cross_platform]).count.positive?
28
+ end
29
+
30
+ private
31
+
32
+ def _initializer
33
+ @_initializer ||= super
34
+ end
35
+ alias initializer _initializer
16
36
  end