Permalink
Browse files

Don’t use any classes with more than two instance variables

  • Loading branch information...
oriolgual committed Feb 12, 2012
1 parent 0ff0a54 commit 3cc0f9466e818e479ace648b3d5a481171b56a6a
Showing with 14 additions and 20 deletions.
  1. +6 −12 lib/spinach/runner/scenario_runner.rb
  2. +8 −8 lib/spinach/runner/step_runner.rb
@@ -27,19 +27,12 @@ def feature
#
# @api public
def steps
+ step_definitions = step_definitions_klass.new
@steps ||=(feature.background_steps + @scenario.steps).map do |step|
StepRunner.new(step, step_definitions)
end
end
- # @return [FeatureSteps]
- # The step definitions for the current feature.
- #
- # @api public
- def step_definitions
- @step_definitions ||= step_definitions_klass.new
- end
-
def step_definitions_klass
Spinach.find_step_definitions(feature.name)
end
@@ -52,25 +45,26 @@ def step_definitions_klass
#
# @api public
def run
+ scenario_runner_mutex = ScenarioRunnerMutex.new
+
hooks.run_before_scenario @scenario
scenario_runner_mutex.deactivate
+
hooks.run_around_scenario @scenario do
scenario_runner_mutex.activate
run_scenario_steps
end
+
raise "around_scenario hooks *must* yield" if !scenario_runner_mutex.active? && success?
hooks.run_after_scenario @scenario
+
!!success?
end
def hooks
Spinach.hooks
end
- def scenario_runner_mutex
- @scenario_runner_mutex ||= ScenarioRunnerMutex.new
- end
-
def run_scenario_steps
previous_step_success = true
steps.each do |step|
@@ -3,7 +3,7 @@ class Runner
class StepRunner
def initialize(step, context)
@step = step
- @exception = false
+ @success = true
@context = context
end
@@ -30,22 +30,22 @@ def execute
@context.execute(@step)
hooks.run_on_successful_step @step, location
rescue *Spinach.config[:failure_exceptions] => exception
- @exception = exception
- hooks.run_on_failed_step @step, @exception, location
+ @success = false
+ hooks.run_on_failed_step @step, exception, location
rescue Spinach::StepNotDefinedException => exception
- @exception = exception
- hooks.run_on_undefined_step @step, @exception
+ @success = false
+ hooks.run_on_undefined_step @step, exception
rescue Exception => exception
- @exception = exception
- hooks.run_on_error_step @step, @exception, location
+ @success = false
+ hooks.run_on_error_step @step, exception, location
end
def hooks
Spinach.hooks
end
def success?
- !@exception
+ @success
end
def location

0 comments on commit 3cc0f94

Please sign in to comment.