Class: RubyRaider::MenuGenerator

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

Class Method Summary collapse

Class Method Details

.choose_mobile_platformObject



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

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

.choose_test_framework(automation, project_name) ⇒ Object



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

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') { framework = 'rspec'; set_framework(automation, framework, project_name) }
    menu.choice('Cucumber') do
      if %w[selenium watir].include? automation
        framework = 'cucumber'
        set_framework(automation, framework, project_name)
      else
        pp 'We will support iOS with cucumber on the next release'
        exit
      end
    end
    menu.choice('Quit') { exit }
  end
  @cli.say("You have chosen to use #{framework} with #{automation}")
end

.generate_choice_menu(project_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/menu_generator.rb', line 8

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



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

def set_framework(automation, framework, project_name)
  if framework == 'rspec'
    RspecProjectGenerator.generate_rspec_project(automation, project_name)
  else
    CucumberProjectGenerator.generate_cucumber_project(automation, project_name)
  end
end