lib/cucumber/executor.rb in aslakhellesoy-cucumber-0.1.12 vs lib/cucumber/executor.rb in aslakhellesoy-cucumber-0.1.13

- old
+ new

@@ -63,10 +63,14 @@ def visit_regular_scenario(scenario) @regular_scenario_cache[scenario.name] = scenario visit_scenario(scenario) end + def visit_scenario_outline(scenario) + visit_regular_scenario(scenario) + end + def visit_scenario(scenario) if accept_scenario?(scenario) @executed_scenarios[scenario.name] = true execute_scenario(scenario) end @@ -75,12 +79,10 @@ def execute_scenario(scenario) @error = nil @pending = nil @world = create_world - @world.extend(Spec::Matchers) if defined?(Spec::Matchers) - define_step_call_methods(@world) formatters.scenario_executing(scenario) @before_scenario_procs.each{|p| p.call_in(@world, *[])} scenario.accept(self) @after_scenario_procs.each{|p| p.call_in(@world, *[])} @@ -102,18 +104,26 @@ def visit_regular_step(step) visit_step(step) end + def visit_step_outline(step) + regexp, args, proc = step.regexp_args_proc(@step_mother) + formatters.step_traced(step, regexp, args) + end + def visit_step(step) unless @pending || @error begin regexp, args, proc = step.regexp_args_proc(@step_mother) formatters.step_executing(step, regexp, args) step.execute_in(@world, regexp, args, proc) @after_step_procs.each{|p| p.call_in(@world, *[])} formatters.step_passed(step, regexp, args) + rescue ForcedPending => e + step.error = e + record_pending_step(step, regexp, args) rescue Pending record_pending_step(step, regexp, args) rescue => e @failed = true @error = step.error = e @@ -122,10 +132,13 @@ else begin regexp, args, proc = step.regexp_args_proc(@step_mother) step.execute_in(@world, regexp, args, proc) formatters.step_skipped(step, regexp, args) + rescue ForcedPending => e + step.error = e + record_pending_step(step, regexp, args) rescue Pending record_pending_step(step, regexp, args) rescue Exception formatters.step_skipped(step, regexp, args) end @@ -135,26 +148,10 @@ def record_pending_step(step, regexp, args) @pending = true formatters.step_pending(step, regexp, args) end - def define_step_call_methods(world) - world.instance_variable_set('@__executor', self) - world.instance_eval do - class << self - def run_step(name) - _, args, proc = @__executor.instance_variable_get(:@step_mother).regexp_args_proc(name) - proc.call_in(self, *args) - end - - %w{given when then and but}.each do |keyword| - alias_method Cucumber.language[keyword], :run_step - end - end - end - end - def executing_unprepared_row_scenario?(scenario) accept_scenario?(scenario) && !@executed_scenarios[scenario.name] end def scenario_at_specified_line?(scenario) @@ -180,9 +177,29 @@ def create_world world = Object.new @world_procs.each do |world_proc| world = world_proc.call(world) end + + world.extend(World::Pending) + world.extend(::Spec::Matchers) if defined?(::Spec::Matchers) + define_step_call_methods(world) world + end + + def define_step_call_methods(world) + world.instance_variable_set('@__executor', self) + world.instance_eval do + class << self + def run_step(name) + _, args, proc = @__executor.instance_variable_get(:@step_mother).regexp_args_proc(name) + proc.call_in(self, *args) + end + + %w{given when then and but}.each do |keyword| + alias_method Cucumber.language[keyword], :run_step + end + end + end end end end