Class: MenuGenerator

Inherits:
Object
  • Object
show all
Includes:
InvokeGenerators
Defined in:
lib/generators/menu_generator.rb

Overview

:reek:FeatureEnvy { enabled: false } :reek:UtilityFunction { enabled: false }

Defined Under Namespace

Classes: FrameworkOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InvokeGenerators

#add_generator, #generate_framework, #invoke_generator

Constructor Details

#initialize(project_name) ⇒ MenuGenerator

Returns a new instance of MenuGenerator.



13
14
15
16
# File 'lib/generators/menu_generator.rb', line 13

def initialize(project_name)
  @prompt = TTY::Prompt.new
  @name = project_name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/generators/menu_generator.rb', line 9

def name
  @name
end

#promptObject (readonly)

Returns the value of attribute prompt.



9
10
11
# File 'lib/generators/menu_generator.rb', line 9

def prompt
  @prompt
end

Instance Method Details

#choose_mobile_platformObject



57
58
59
60
61
62
63
64
# File 'lib/generators/menu_generator.rb', line 57

def choose_mobile_platform
  prompt.select('Please select your mobile platform') do |menu|
    menu.choice :iOS, -> { choose_test_framework 'ios' }
    menu.choice :Android, -> { choose_test_framework 'android' }
    menu.choice :Cross_Platform, -> { choose_test_framework 'cross_platform' }
    menu.choice :Quit, -> { exit }
  end
end

#choose_sparkling_platformObject



50
51
52
53
54
55
# File 'lib/generators/menu_generator.rb', line 50

def choose_sparkling_platform
  prompt.select('Please select your mobile platform') do |menu|
    menu.choice :iOS, -> { choose_test_framework 'sparkling_ios' }
    menu.choice :Quit, -> { exit }
  end
end

#choose_test_framework(automation) ⇒ Object



32
33
34
35
36
37
# File 'lib/generators/menu_generator.rb', line 32

def choose_test_framework(automation)
  return choose_mobile_platform if automation == 'appium'
  return choose_sparkling_platform if automation == 'sparkling'

  select_test_framework(automation)
end

#choose_visual_automationObject



28
29
30
# File 'lib/generators/menu_generator.rb', line 28

def choose_visual_automation
  prompt.select('Do you want to add visual automation with applitools?', visual_automation_menu_choices)
end

#generate_choice_menuObject



18
19
20
21
22
23
24
25
26
# File 'lib/generators/menu_generator.rb', line 18

def generate_choice_menu
  prompt.select('Please select your automation framework') do |menu|
    menu.choice :Appium, -> { choose_test_framework('appium') }
    menu.choice :Selenium, -> { choose_test_framework('selenium') }
    menu.choice 'Sparkling Watir', -> { choose_test_framework('sparkling') }
    menu.choice :Watir, -> { choose_test_framework('watir') }
    menu.choice :Quit, -> { exit }
  end
end

#set_up_framework(options) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/menu_generator.rb', line 39

def set_up_framework(options)
  structure = {
    automation: options[:automation],
    framework: options[:framework],
    name: @name,
    visual: options[:visual_automation]
  }
  generate_framework(structure)
  system "cd #{name} && gem install bundler && bundle install"
end