Class: Cucumber::Cli::Main
Defined Under Namespace
Classes: LogFormatter
Constant Summary collapse
- FAILURE =
1
Class Method Summary collapse
Instance Method Summary collapse
- #configuration ⇒ Object
- #exceeded_tag_limts?(features) ⇒ Boolean
- #execute!(step_mother) ⇒ Object
-
#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main
constructor
A new instance of Main.
- #verbose_log(string) ⇒ Object
Constructor Details
#initialize(args, out_stream = STDOUT, error_stream = STDERR) ⇒ Main
Returns a new instance of Main.
33 34 35 36 37 |
# File 'lib/cucumber/cli/main.rb', line 33 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
28 29 30 |
# File 'lib/cucumber/cli/main.rb', line 28 def execute(args) new(args).execute!(step_mother) end |
.step_mother ⇒ Object
24 25 26 |
# File 'lib/cucumber/cli/main.rb', line 24 def step_mother @step_mother ||= StepMother.new end |
Instance Method Details
#configuration ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/cucumber/cli/main.rb', line 92 def configuration return @configuration if @configuration @configuration = Configuration.new(@out_stream, @error_stream) @configuration.parse!(@args) @configuration end |
#exceeded_tag_limts?(features) ⇒ Boolean
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cucumber/cli/main.rb', line 79 def exceeded_tag_limts?(features) exceeded = false configuration.[:include_tags].each do |tag, limit| unless limit.nil? tag_count = features.tag_count(tag) if tag_count > limit.to_i exceeded = true end end end exceeded end |
#execute!(step_mother) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cucumber/cli/main.rb', line 39 def execute!(step_mother) trap_interrupt if configuration.drb? begin return DRbClient.run(@args, @error_stream, @out_stream, configuration.drb_port) rescue DRbClientError => e @error_stream.puts "WARNING: #{e.} Running features locally:" end end step_mother. = configuration. logger = Logger.new(@out_stream) logger.formatter = LogFormatter.new logger.level = Logger::INFO logger.level = Logger::DEBUG if configuration.verbose? step_mother.log = logger step_mother.load_code_files(configuration.support_to_load) step_mother.after_configuration(configuration) features = step_mother.load_plain_text_features(configuration.feature_files) step_mother.load_code_files(configuration.step_defs_to_load) enable_diffing visitor = configuration.build_formatter_broadcaster(step_mother) step_mother.visitor = visitor # Needed to support World#announce visitor.visit_features(features) failure = if exceeded_tag_limts?(features) FAILURE elsif configuration.wip? step_mother.scenarios(:passed).any? else step_mother.scenarios(:failed).any? || (configuration.strict? && (step_mother.steps(:undefined).any? || step_mother.steps(:pending).any?)) end rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e @error_stream.puts e. true end |
#verbose_log(string) ⇒ Object
100 101 102 |
# File 'lib/cucumber/cli/main.rb', line 100 def verbose_log(string) @out_stream.puts(string) if configuration.verbose? end |