ruby_raider 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +195 -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 +6 -1
  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: c0bace14246d3e24dce83a371be3cd3b5149e7613a2f467e5258cf08f4f429c5
4
+ data.tar.gz: 25ff01178be1c28a0f8f183bbb7e1364b6205a0f941f6166e7b87281e36c7ba7
5
5
  SHA512:
6
- metadata.gz: 8d2bbcec5a84038878369fb76d31ae8965abcf9300b7aa02957ca0ff2c4244e74c8ecd195dbb7eb053218974bc286b99fac6074baafdb40af021a5e75b56ed3b
7
- data.tar.gz: 987a2a4fe907958384ba1e1ccd110987bbff1cd497577f5f51621fd3ab4bdaffdceff43bbe829ec0c9847fe7fe5ad470047da5a1c9040af29172458248f9cbd4
6
+ metadata.gz: 06372caf14ab5bf242cdf8a87843e1e4ccc078f7f65542580fb5c793f0c679834050f5661a6554c52bde84d95f63bf90f8db276f10d9e4c4563093ea83ac9702
7
+ data.tar.gz: 2b4ddad1c0743eb57f3b051c1c5abb7d28923b0a0f7fb2fa24309b9b357894b5e0257b721aa9e5a9e4986ad3bba02494a8328295a9a42f8237e0ed5c1252ad21
@@ -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,195 @@
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 initialize
13
+ super
14
+ @folder_exist = File.directory?(@folder)
15
+ end
16
+
17
+ def header
18
+ grid do
19
+ stretchy false
20
+
21
+ button('▶') do
22
+ left 0
23
+ on_clicked do
24
+ output = Open3.popen3("#{@framework} #{@tests.selected_item}") do |_stdin, stdout, _stderr|
25
+ stdout.read
26
+ end
27
+ system "#{@framework} #{@tests.selected_item}"
28
+ @results.text = output
29
+ end
30
+ end
31
+ button('■') do
32
+ left 1
33
+ on_clicked do
34
+ pp 'The stop feature will be implemented in a later release'
35
+ end
36
+ end
37
+
38
+ @tests = combobox do
39
+ left 2
40
+ files = Dir.glob(File.join(@folder, @extension))
41
+ multiple_items = files.count.positive? ? files : ['There are no tests please create a new one']
42
+ items multiple_items
43
+ selected_item files.first
44
+ @file = files.count.positive? ? File.open(files.first) : ''
45
+
46
+ on_selected do |items|
47
+ @results.text = ''
48
+ path = items.selected_item
49
+ @file = File.open(path)
50
+ @text_box.text = @file.read
51
+ end
52
+ end
53
+
54
+ button('Open Dashboard') do
55
+ left 3
56
+ halign :end
57
+ on_clicked do
58
+ system 'allure serve allure-reports'
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ def tests_tab
65
+ tab_item('Tests') do
66
+ horizontal_box do
67
+ @text_box = multiline_entry do
68
+ test_code = @folder_exist ? @file.read : 'No tests have been created, please create your first test'
69
+ text test_code
70
+
71
+ on_changed do |e|
72
+ File.write(@tests.selected_item, e.text)
73
+ $stdout.flush # for Windows
74
+ end
75
+ end
76
+
77
+ @results = multiline_entry do
78
+ text ''
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ def config_tab
85
+ tab_item('Configuration') do
86
+ @config_data = load_or_create_config
87
+ @config_items = @config_data.map { |key, value| CONFIG_ITEM.new(key, value) }
88
+ vertical_box do
89
+ refined_table(
90
+ model_array: @config_items,
91
+ table_columns: {
92
+ 'Attribute' => :text,
93
+ 'Value' => { text: { editable: true } }
94
+ },
95
+ table_editable: true,
96
+ per_page: 20
97
+ )
98
+ end
99
+ end
100
+ end
101
+
102
+ def editor_tab
103
+ tab_item('Editor') do
104
+ horizontal_box do
105
+ vertical_box do
106
+ horizontal_box do
107
+ button('Create Test') do
108
+ on_clicked do
109
+ Scaffolding.new([@test_name.text]).generate_spec
110
+ end
111
+ end
112
+ @test_name = entry do
113
+ text 'test_example'
114
+ end
115
+ end
116
+ horizontal_box do
117
+ button('Create Page') do
118
+ on_clicked do
119
+ Scaffolding.new([@page_name.text]).generate_class
120
+ end
121
+ end
122
+ @page_name = entry do
123
+ text 'page_example'
124
+ end
125
+ end
126
+ horizontal_box do
127
+ button('Create Helper') do
128
+ on_clicked do
129
+ Scaffolding.new([@helper_name.text]).generate_helper
130
+ end
131
+ end
132
+ @helper_name = entry do
133
+ text 'helper_example'
134
+ end
135
+ end
136
+ vertical_separator do
137
+ stretchy false
138
+ end
139
+ end
140
+ vertical_box do
141
+ @editable_files = combobox do
142
+ @all_files = @folder_exist ? load_all_files : ['There are no files created']
143
+ stretchy false
144
+ visible true
145
+ items @all_files
146
+ selected_item @all_files.first
147
+
148
+ on_selected do |items|
149
+ if @folder_exist
150
+ path = items.selected_item
151
+ @edit_file = File.open(path)
152
+ @edit_box.text = @edit_file.read
153
+ end
154
+ end
155
+ end
156
+ @edit_box = multiline_entry do
157
+ text File.read(@all_files.first) if @folder_exist
158
+
159
+ on_changed do |e|
160
+ if @folder_exist
161
+ File.write(@editable_files.selected_item, e.text)
162
+ $stdout.flush # for Windows
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+
171
+ private
172
+
173
+ def load_all_files
174
+ test_files = Dir.glob(File.join(@folder, @extension))
175
+ page_object_files = Dir.glob(File.join('page_objects/pages', '*.rb'))
176
+ helper_files = Dir.glob(File.join('helpers', '*.rb'))
177
+ test_files + page_object_files + helper_files
178
+ end
179
+
180
+ def load_or_create_config
181
+ file_paths = {
182
+ config: 'config/config.yml',
183
+ caps: 'config/capabilities.yml',
184
+ opts: 'config/options.yml'
185
+ }
186
+
187
+ loaded_files = file_paths.transform_values do |path|
188
+ File.exist?(path) ? YAML.load_file(path) : {}
189
+ end
190
+
191
+ return { message: 'Create a config file to access your attributes' } if loaded_files.values.all?(&:empty?)
192
+
193
+ loaded_files[:config].merge(loaded_files[:caps]).merge(loaded_files[:opts])
194
+ end
195
+ 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