lib/gurke/step.rb in gurke-2.0.0.dev.1.b20 vs lib/gurke/step.rb in gurke-2.0.0.dev.1.b22
- old
+ new
@@ -1,7 +1,6 @@
module Gurke
- #
class Step
#
# Return path to file containing this scenario.
#
# @return [String] File path.
@@ -53,31 +52,33 @@
private
def run_step(runner, reporter, scenario, world)
reporter.invoke :start_step, self, scenario
- result = nil
+ result = find_and_run_step runner, scenario, world
+ rescue StepPending => e
+ scenario.pending! e
+ result = StepResult.new self, :pending, e
+ rescue => e
+ scenario.failed! e
+ result = StepResult.new self, :failed, e
+ ensure
+ reporter.invoke :end_step, result, scenario
+ end
+
+ def find_and_run_step(runner, scenario, world)
runner.with_filtered_backtrace do
match = Steps.find_step self, world, type
if scenario.pending? || scenario.failed?
- result = StepResult.new self, :skipped
- return result
+ return StepResult.new self, :skipped
end
m = world.method match.method_name
world.send match.method_name, *(match.params + [self])[0...m.arity]
- end
- result = StepResult.new self, :success
- rescue StepPending => e
- scenario.pending! e
- result = StepResult.new self, :pending, e
- rescue => e
- scenario.failed! e
- result = StepResult.new self, :failed, e
- ensure
- reporter.invoke :end_step, result, scenario
+ StepResult.new self, :success
+ end
end
#
class StepResult
attr_reader :step, :exception, :state