lib/smokes/cli.rb in smokes-0.1.1 vs lib/smokes/cli.rb in smokes-0.1.2
- old
+ new
@@ -1,6 +1,8 @@
module Smokes
+ # Main Class that runs the cli
+ # The Main cli methods are 'new' and 'start'
class Cli < Thor
include Thor::Actions
def self.source_root
File.dirname __FILE__
@@ -21,11 +23,12 @@
desc 'start', 'Runs the test suite'
def start
check_cfg_file
check_main_file
- get_test_selection
+ test_selections
+ Smokes::TestsLoader.new(@url, @selected_tests, @config_variables).run
end
private
def get_site_title(url)
@@ -35,12 +38,12 @@
@title = "#We encountered issue verifying '#{@url}'. Please verify it at '#{@name}/main.smoke'"
end
def check_cfg_file
unless File.file?('smokes.cfg')
- say('smokes.cfg was not found. Generating...'.colorize(:blue))
- template 'templates/smokes.tt', "smokes.cfg"
+ say('Generating "smokes.cfg" because it was not found'.colorize(:blue))
+ template 'templates/smokes.tt', 'smokes.cfg'
say('smokes.cfg was successfully generated'.colorize(:grey))
end
begin
@config_variables = TomlRB.load_file('smokes.cfg', symbolize_keys: true)[:defaults]
rescue StandardError => e
@@ -61,17 +64,13 @@
rescue StandardError => error
puts error
abort
end
- def get_test_selection
+ def test_selections
prompt = TTY::Prompt.new active_color: :green
- puts "\n"
- options = prompt.multi_select("Select tests to run: \n".colorize(:blue), (@all_tests << 'All'))
- if options.include?('All')
- @selected_tests = @all_tests
- else
- @selected_tests = options
- end
+ tests = @all_tests.dup << 'All'
+ options = prompt.multi_select "Select tests to run: \n".colorize(:blue), tests
+ @selected_tests = options.include?('All') ? @all_tests : options
end
end
end