Class: Cucumber::Cli::Main

Inherits:
Object show all
Defined in:
lib/cucumber/cli/main.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Main) initialize(args, _ = nil, out = STDOUT, err = STDERR, kernel = Kernel)

Returns a new instance of Main



21
22
23
24
25
26
# File 'lib/cucumber/cli/main.rb', line 21

def initialize(args, _=nil, out=STDOUT, err=STDERR, kernel=Kernel)
  @args   = args
  @out    = out
  @err    = err
  @kernel = kernel
end

Class Method Details

+ (Object) execute(args)



16
17
18
# File 'lib/cucumber/cli/main.rb', line 16

def execute(args)
  new(args).execute!
end

Instance Method Details

- (Object) configuration



63
64
65
66
67
68
# File 'lib/cucumber/cli/main.rb', line 63

def configuration
  @configuration ||= Configuration.new(@out, @err).tap do |configuration|
    configuration.parse!(@args)
    Cucumber.logger = configuration.log
  end
end

- (Object) execute!(existing_runtime = nil)



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cucumber/cli/main.rb', line 28

def execute!(existing_runtime = nil)
  trap_interrupt

  runtime = if existing_runtime
    existing_runtime.configure(configuration)
    existing_runtime
  else
    Runtime.new(configuration)
  end

  runtime.run!
  runtime.write_stepdefs_json
  failure = runtime.results.failure? || Cucumber.wants_to_quit
  @kernel.exit(failure ? 1 : 0)
rescue FileNotFoundException => e
  @err.puts(e.message)
  @err.puts("Couldn't open #{e.path}")
  @kernel.exit(1)
rescue FeatureFolderNotFoundException => e
  @err.puts(e.message + ". Please create a #{e.path} directory to get started.")
  @kernel.exit(1)
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
  @err.puts(e.message)
  @kernel.exit(1)
rescue SystemExit => e
  @kernel.exit(e.status)
rescue Errno::EACCES, Errno::ENOENT => e
  @err.puts("#{e.message} (#{e.class})")
  @kernel.exit(1)
rescue Exception => e
  @err.puts("#{e.message} (#{e.class})")
  @err.puts(e.backtrace.join("\n"))
  @kernel.exit(1)
end