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

#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main

Returns a new instance of Main.



24
25
26
27
28
# File 'lib/cucumber/cli/main.rb', line 24

def initialize(args, out_stream = STDOUT, error_stream = STDERR)
  @args         = args
  @out_stream   = out_stream == STDOUT ? Formatter::ColorIO.new : out_stream
  @error_stream = error_stream
end

Class Method Details

.execute(args) ⇒ Object



19
20
21
# File 'lib/cucumber/cli/main.rb', line 19

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

.step_mother=(step_mother) ⇒ Object



13
14
15
16
17
# File 'lib/cucumber/cli/main.rb', line 13

def step_mother=(step_mother)
  @step_mother = step_mother
  @step_mother.extend(StepMother)
  @step_mother.snippet_generator = StepDefinition
end

Instance Method Details

#execute!(step_mother) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cucumber/cli/main.rb', line 30

def execute!(step_mother)
  configuration.load_language
  step_mother.options = configuration.options

  require_files

  if(configuration.print_step_definitions?)
    step_mother.print_step_definitions(@out_stream)
    Kernel.exit(0)
    return # In specs, exit is stubbed
  end
  
  enable_diffing

  features = load_plain_text_features

  visitor = configuration.build_formatter_broadcaster(step_mother)
  visitor.visit_features(features)

  failure = features.steps[:failed].any? || (configuration.strict? && features.steps[:undefined].any?)
  Kernel.exit(failure ? 1 : 0)
end