Module | Spec::Example::ExampleMethods |
In: |
lib/spec/example/example_methods.rb
|
PENDING_EXAMPLE_BLOCK | = | lambda { raise Spec::Example::ExamplePendingError.new("Not Yet Implemented") |
# File lib/spec/example/example_methods.rb, line 63 63: def description 64: @_defined_description || @_matcher_description || "NO NAME" 65: end
# File lib/spec/example/example_methods.rb, line 11 11: def execute(options, instance_variables) 12: options.reporter.example_started(self) 13: set_instance_variables_from_hash(instance_variables) 14: 15: execution_error = nil 16: Timeout.timeout(options.timeout) do 17: begin 18: before_example 19: run_with_description_capturing 20: rescue Exception => e 21: execution_error ||= e 22: end 23: begin 24: after_example 25: rescue Exception => e 26: execution_error ||= e 27: end 28: end 29: 30: options.reporter.example_finished(self, execution_error) 31: success = execution_error.nil? || ExamplePendingError === execution_error 32: end
# File lib/spec/example/example_methods.rb, line 85 85: def implementation_backtrace 86: eval("caller", @_implementation) 87: end
# File lib/spec/example/example_methods.rb, line 34 34: def instance_variable_hash 35: instance_variables.inject({}) do |variable_hash, variable_name| 36: variable_hash[variable_name] = instance_variable_get(variable_name) 37: variable_hash 38: end 39: end
# File lib/spec/example/example_methods.rb, line 76 76: def run_with_description_capturing 77: begin 78: return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK)) 79: ensure 80: @_matcher_description = Spec::Matchers.generated_description 81: Spec::Matchers.clear_generated_description 82: end 83: end
# File lib/spec/example/example_methods.rb, line 67 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 72: end 73: end 74: end
# File lib/spec/example/example_methods.rb, line 41 41: def violated(message="") 42: raise Spec::Expectations::ExpectationNotMetError.new(message) 43: end
# File lib/spec/example/example_methods.rb, line 98 98: def after_example 99: self.class.run_after_each(self) 100: verify_mocks_for_rspec 101: ensure 102: teardown_mocks_for_rspec 103: end