Class: MenuGenerator

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

Class Method Summary collapse

Class Method Details

.choose_mobile_platformObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/generators/menu_generator.rb', line 55

def choose_mobile_platform
  @cli.choose do |menu|
    menu.prompt = 'Please select your mobile platform'
    menu.choice('iOS') { 'appium_ios' }
    menu.choice('Android') do
      pp 'Android appium is coming soon. Thank you for the interest'
      exit
    end
    menu.choice('Cross Platform') do
      pp 'Cross platform appium is coming soon. Thank you for the interest'
      exit
    end
    menu.choice('Quit') { exit }
  end
end

.choose_test_framework(automation, project_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/menu_generator.rb', line 23

def choose_test_framework(automation, project_name)
  system('clear') || system('cls')
  sleep 0.3
  automation = automation == 'appium' ? choose_mobile_platform : automation
  framework = ''
  @cli.choose do |menu|
    menu.prompt = 'Please select your test framework'
    menu.choice('Rspec') do
      framework = 'rspec'
      set_framework(automation, framework, project_name)
    end
    menu.choice('Cucumber') do
      framework = 'cucumber'
      set_framework(automation, framework, project_name)
    end
    menu.choice('Quit') { exit }
  end
  @cli.say("You have chosen to use #{framework} with #{automation}")
end

.generate_choice_menu(project_name) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/menu_generator.rb', line 12

def generate_choice_menu(project_name)
  @cli = HighLine.new
  @cli.choose do |menu|
    menu.prompt = 'Please select your automation framework'
    menu.choice('Selenium') { choose_test_framework('selenium', project_name) }
    menu.choice('Watir') { choose_test_framework('watir', project_name) }
    menu.choice('Appium') { choose_test_framework('appium', project_name) }
    menu.choice('Quit') { exit }
  end
end

.set_framework(automation, framework, project_name) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/generators/menu_generator.rb', line 43

def set_framework(automation, framework, project_name)
  if framework == 'rspec'
    RspecGenerator.new([automation, framework, project_name]).invoke_all
  else
    CucumberGenerator.new([automation, framework, project_name]).invoke_all
  end
  AutomationGenerator.new([automation, framework, project_name]).invoke_all
  CommonGenerator.new([automation, framework, project_name]).invoke_all
  HelpersGenerator.new([automation, framework, project_name]).invoke_all
  system "cd #{project_name} && gem install bundler && bundle install"
end