Skip to content

Commit

Permalink
Start adding RBS support
Browse files Browse the repository at this point in the history
  • Loading branch information
aguspe committed Jul 25, 2024
1 parent 5cd5516 commit a6aa903
Show file tree
Hide file tree
Showing 29 changed files with 785 additions and 432 deletions.
121 changes: 62 additions & 59 deletions lib/commands/utility_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,76 +5,79 @@

# :reek:FeatureEnvy { enabled: false }
# :reek:UtilityFunction { enabled: false }
class UtilityCommands < Thor
desc 'path [PATH]', 'Sets the default path for scaffolding'
option :feature,
type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
option :helper,
type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
option :spec,
type: :boolean, required: false, desc: 'The default path for your specs', aliases: '-s'

def path(default_path)
type = options.empty? ? 'page' : options.keys.first
Utilities.send("#{type}_path=", default_path)
end
module RubyRaider
class UtilityCommands < Thor
desc 'path [PATH]', 'Sets the default path for scaffolding'
option :feature,
type: :boolean, required: false, desc: 'The default path for your features', aliases: '-f'
option :helper,
type: :boolean, required: false, desc: 'The default path for your helpers', aliases: '-h'
option :spec,
type: :boolean, required: false, desc: 'The default path for your specs', aliases: '-s'

desc 'url [URL]', 'Sets the default url for a project'
def path(default_path)
type = options.empty? ? 'page' : options.keys.first
Utilities.send("#{type}_path=", default_path)
end

def url(default_url)
Utilities.url = default_url
end
desc 'url [URL]', 'Sets the default url for a project'

desc 'browser [BROWSER]', 'Sets the default browser for a project'
option :opts,
type: :array, required: false, desc: 'The options you want your browser to run with', aliases: '-o'
option :delete,
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
def url(default_url)
Utilities.url = default_url
end

def browser(default_browser = nil)
Utilities.browser = default_browser if default_browser
selected_options = options[:opts]
browser_options(selected_options) if selected_options || options[:delete]
end
desc 'browser [BROWSER]', 'Sets the default browser for a project'
option :opts,
type: :array, required: false, desc: 'The options you want your browser to run with', aliases: '-o'
option :delete,
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'

desc 'browser_options [OPTIONS]', 'Sets the browser options for the project'
option :delete,
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
def browser(default_browser = nil)
Utilities.browser = default_browser if default_browser
selected_options = options[:opts]
browser_options(selected_options) if selected_options || options[:delete]
end

def browser_options(*opts)
Utilities.browser_options = opts unless opts.empty?
Utilities.delete_browser_options if options[:delete]
end
desc 'browser_options [OPTIONS]', 'Sets the browser options for the project'
option :delete,
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'

desc 'raid', 'It runs all the tests in a project'
option :parallel,
type: :boolean, required: false, desc: 'It runs the tests in parallel', aliases: '-p'
option :opts,
type: :array, required: false, desc: 'The options that your run will run with', aliases: '-o'

def raid
selected_options = options[:opts]
if options[:parallel]
Utilities.parallel_run(selected_options)
else
Utilities.run(selected_options)
def browser_options(*opts)
Utilities.browser_options = opts unless opts.empty?
Utilities.delete_browser_options if options[:delete]
end
end

desc 'config', 'Creates a new config file'
option :path,
type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
option :delete,
type: :boolean, required: false, desc: 'This will delete the selected config file', aliases: '-d'
desc 'raid', 'It runs all the tests in a project'
option :parallel,
type: :boolean, required: false, desc: 'It runs the tests in parallel', aliases: '-p'
option :opts,
type: :array, required: false, desc: 'The options that your run will run with', aliases: '-o'

desc 'platform [PLATFORM]', 'Sets the default platform for a cross-platform project'
def raid
selected_options = options[:opts]
if options[:parallel]
Utilities.parallel_run(selected_options)
else
Utilities.run(selected_options)
end
end

def platform(platform)
Utilities.platform = platform
end
desc 'config', 'Creates a new config file'
option :path,
type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
option :delete,
type: :boolean, required: false, desc: 'This will delete the selected config file', aliases: '-d'

desc 'start_appium', 'It starts the appium server'
def start_appium
system 'appium --base-path /wd/hub'
desc 'platform [PLATFORM]', 'Sets the default platform for a cross-platform project'

def platform(platform)
Utilities.platform = platform
end

desc 'start_appium', 'It starts the appium server'

def start_appium
system 'appium --base-path /wd/hub'
end
end
end
10 changes: 6 additions & 4 deletions lib/generators/actions/actions_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

require_relative '../generator'

class ActionsGenerator < Generator
def generate_actions_file
return unless web?
module RubyRaider
class ActionsGenerator < Generator
def generate_actions_file
return unless web?

template('actions.tt', "#{name}/.github/workflows/test_pipeline.yml")
template('actions.tt', "#{name}/.github/workflows/test_pipeline.yml")
end
end
end
122 changes: 62 additions & 60 deletions lib/generators/automation/automation_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,84 @@

require_relative '../generator'

class AutomationGenerator < Generator
def generate_automation_files
if mobile?
generate_appium_settings
generate_home_page
generate_pdp_page
else
generate_visual_options
generate_components
generate_model_files
generate_pages
module RubyRaider
class AutomationGenerator < Generator
def generate_automation_files
if mobile?
generate_appium_settings
generate_home_page
generate_pdp_page
else
generate_visual_options
generate_components
generate_model_files
generate_pages
end

generate_abstract_page
end

generate_abstract_page
end

private
private

def generate_pages
generate_login_page
generate_account_page
end
def generate_pages
generate_login_page
generate_account_page
end

def generate_components
generate_abstract_component
generate_header_component
end
def generate_components
generate_abstract_component
generate_header_component
end

def generate_model_files
generate_model_factory
generate_model_data
end
def generate_model_files
generate_model_factory
generate_model_data
end

def generate_abstract_page
template('page.tt', "#{name}/page_objects/abstract/page.rb")
end
def generate_abstract_page
template('page.tt', "#{name}/page_objects/abstract/page.rb")
end

def generate_abstract_component
template('component.tt', "#{name}/page_objects/abstract/component.rb")
end
def generate_abstract_component
template('component.tt', "#{name}/page_objects/abstract/component.rb")
end

def generate_appium_settings
template('appium_caps.tt', "#{name}/config/capabilities.yml")
end
def generate_appium_settings
template('appium_caps.tt', "#{name}/config/capabilities.yml")
end

def generate_visual_options
return unless visual?
def generate_visual_options
return unless visual?

template('visual_options.tt', "#{name}/config/options.yml")
end
template('visual_options.tt', "#{name}/config/options.yml")
end

def generate_login_page
template('login.tt', "#{name}/page_objects/pages/login.rb")
end
def generate_login_page
template('login.tt', "#{name}/page_objects/pages/login.rb")
end

def generate_account_page
template('account.tt', "#{name}/page_objects/pages/account.rb")
end
def generate_account_page
template('account.tt', "#{name}/page_objects/pages/account.rb")
end

def generate_home_page
template('home.tt', "#{name}/page_objects/pages/home.rb")
end
def generate_home_page
template('home.tt', "#{name}/page_objects/pages/home.rb")
end

def generate_pdp_page
template('pdp.tt', "#{name}/page_objects/pages/pdp.rb")
end
def generate_pdp_page
template('pdp.tt', "#{name}/page_objects/pages/pdp.rb")
end

def generate_header_component
template('header.tt', "#{name}/page_objects/components/header.rb")
end
def generate_header_component
template('header.tt', "#{name}/page_objects/components/header.rb")
end

def generate_model_factory
template('factory.tt', "#{name}/models/model_factory.rb")
end
def generate_model_factory
template('factory.tt', "#{name}/models/model_factory.rb")
end

def generate_model_data
template('data.tt', "#{name}/models/data/users.yml")
def generate_model_data
template('data.tt', "#{name}/models/data/users.yml")
end
end
end
52 changes: 27 additions & 25 deletions lib/generators/common_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,40 @@

require_relative 'generator'

class CommonGenerator < Generator
def generate_readme_file
template('common/read_me.tt', "#{name}/Readme.md")
end
module RubyRaider
class CommonGenerator < Generator
def generate_readme_file
template('common/read_me.tt', "#{name}/Readme.md")
end

def generate_config_file
return if single_platform?
def generate_config_file
return if single_platform?

template('common/config.tt', "#{name}/config/config.yml")
end
template('common/config.tt', "#{name}/config/config.yml")
end

def generate_rake_file
template('common/rakefile.tt', "#{name}/Rakefile")
end
def generate_rake_file
template('common/rakefile.tt', "#{name}/Rakefile")
end

def generate_gemfile
template('common/gemfile.tt', "#{name}/Gemfile")
end
def generate_gemfile
template('common/gemfile.tt', "#{name}/Gemfile")
end

def generate_reek_file
template('common/reek.tt', "#{name}/.reek.yml")
end
def generate_reek_file
template('common/reek.tt', "#{name}/.reek.yml")
end

def generate_rubocop_file
template('common/rubocop.tt', "#{name}/.rubocop.yml")
end
def generate_rubocop_file
template('common/rubocop.tt', "#{name}/.rubocop.yml")
end

def generate_gitignore_file
template('common/git_ignore.tt', "#{name}/.gitignore")
end
def generate_gitignore_file
template('common/git_ignore.tt', "#{name}/.gitignore")
end

def create_allure_folder
empty_directory "#{name}/allure-results"
def create_allure_folder
empty_directory "#{name}/allure-results"
end
end
end
Loading

0 comments on commit a6aa903

Please sign in to comment.