Class: Cucumber::Ast::StepInvocation

Inherits:
Object
  • Object
show all
Defined in:
lib/cuke-step-bm.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#invoke(step_mother, configuration) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/cuke-step-bm.rb', line 65

def invoke(step_mother, configuration)
  exec_proc = Proc.new {
    find_step_match!(step_mother, configuration)
      unless @skip_invoke || configuration.dry_run? || @exception || @step_collection.exception
        @skip_invoke = true
        begin
          @step_match.invoke(@multiline_arg)
          step_mother.after_step
          status!(:passed)
        rescue Pending => e
          failed(configuration, e, false)
          status!(:pending)
        rescue Undefined => e
          failed(configuration, e, false)
          status!(:undefined)
        rescue Cucumber::Ast::Table::Different => e
          @different_table = e.table
          failed(configuration, e, false)
          status!(:failed)
        rescue Exception => e
          failed(configuration, e, false)
          status!(:failed)
        end
      end
  }

  if (CukeStepBm.output_mode == :bm) && defined?(Benchmark)
    Benchmark.bm do |reporter|
      reporter.report("Time consuming:") { exec_proc.call }
    end
  else
    time_begin = Time.now
    exec_proc.call
    time_end = Time.now
    time_for_output = "Step consume %s seconds.\n" % ["#{time_end - time_begin}"]
    time_consuming_message = ["#{time_end - time_begin}", @name, file_colon_line].join(CukeStepBm.delimiter)
    time_consuming_message << "\n"
    if CukeStepBm.output_mode == :std_with_log
      puts time_for_output
      CukeStepBm.write_to_log time_consuming_message
    else
      puts time_for_output
    end
  end
end