class Cucumber::Cli::Main
Public Class Methods
execute(args)
click to toggle source
# File lib/cucumber/cli/main.rb, line 11 def execute(args) new(args).execute! end
new(args, _ = nil, out = STDOUT, err = STDERR, kernel = Kernel)
click to toggle source
# File lib/cucumber/cli/main.rb, line 16 def initialize(args, _ = nil, out = STDOUT, err = STDERR, kernel = Kernel) @args = args @out = out @err = err @kernel = kernel end
Public Instance Methods
configuration()
click to toggle source
# File lib/cucumber/cli/main.rb, line 57 def configuration @configuration ||= Configuration.new(@out, @err).tap do |configuration| configuration.parse!(@args) Cucumber.logger = configuration.log end end
execute!(existing_runtime = nil)
click to toggle source
# File lib/cucumber/cli/main.rb, line 23 def execute!(existing_runtime = nil) trap_interrupt runtime = runtime(existing_runtime) runtime.run! if Cucumber.wants_to_quit exit_unable_to_finish elsif runtime.failure? exit_tests_failed else exit_ok end rescue SystemExit => e @kernel.exit(e.status) rescue FileNotFoundException => e @err.puts(e.message) @err.puts("Couldn't open #{e.path}") exit_unable_to_finish rescue FeatureFolderNotFoundException => e @err.puts(e.message + '. You can use `cucumber --init` to get started.') exit_unable_to_finish rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @err.puts(e.message) exit_unable_to_finish rescue Errno::EACCES, Errno::ENOENT => e @err.puts("#{e.message} (#{e.class})") exit_unable_to_finish rescue Exception => e # rubocop:disable Lint/RescueException @err.puts("#{e.message} (#{e.class})") @err.puts(e.backtrace.join("\n")) exit_unable_to_finish end
Private Instance Methods
exit_ok()
click to toggle source
# File lib/cucumber/cli/main.rb, line 66 def exit_ok @kernel.exit 0 end
exit_tests_failed()
click to toggle source
# File lib/cucumber/cli/main.rb, line 70 def exit_tests_failed @kernel.exit 1 end
exit_unable_to_finish()
click to toggle source
# File lib/cucumber/cli/main.rb, line 74 def exit_unable_to_finish @kernel.exit 2 end
exit_unable_to_finish!()
click to toggle source
stops the program immediately, without running at_exit blocks
# File lib/cucumber/cli/main.rb, line 79 def exit_unable_to_finish! @kernel.exit! 2 end
runtime(existing_runtime)
click to toggle source
# File lib/cucumber/cli/main.rb, line 92 def runtime(existing_runtime) return Runtime.new(configuration) unless existing_runtime existing_runtime.configure(configuration) existing_runtime end
trap_interrupt()
click to toggle source
# File lib/cucumber/cli/main.rb, line 83 def trap_interrupt trap('INT') do exit_unable_to_finish! if Cucumber.wants_to_quit Cucumber.wants_to_quit = true STDERR.puts "\nExiting... Interrupt again to exit immediately." exit_unable_to_finish end end