4 extend ExampleGroupMethods
5 extend ModuleReopeningFix
7 PENDING_EXAMPLE_BLOCK = lambda {
8 raise Spec::Example::ExamplePendingError.new("Not Yet Implemented")
11 def execute(options, instance_variables)
12 options.reporter.example_started(self)
13 set_instance_variables_from_hash(instance_variables)
16 Timeout.timeout(options.timeout) do
19 run_with_description_capturing
30 options.reporter.example_finished(self, execution_error)
31 success = execution_error.nil? || ExamplePendingError === execution_error
34 def instance_variable_hash
35 instance_variables.inject({}) do |variable_hash, variable_name|
36 variable_hash[variable_name] = instance_variable_get(variable_name)
41 def violated(message="")
42 raise Spec::Expectations::ExpectationNotMetError.new(message)
45 def eval_each_fail_fast(procs) #:nodoc:
51 def eval_each_fail_slow(procs) #:nodoc:
60 raise first_exception if first_exception
64 @_defined_description || @_matcher_description || "NO NAME"
67 def set_instance_variables_from_hash(ivars)
68 ivars.each do |variable_name, value|
69 # Ruby 1.9 requires variable.to_s on the next line
70 unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s)
71 instance_variable_set variable_name, value
76 def run_with_description_capturing
78 return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
80 @_matcher_description = Spec::Matchers.generated_description
81 Spec::Matchers.clear_generated_description
91 self.class.run_before_each(self)
95 self.class.run_after_each(self)
96 verify_mocks_for_rspec
98 teardown_mocks_for_rspec