| 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 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 75
75: def run_with_description_capturing
76: return_value = nil
77:
78: @_matcher_description = Matchers.capture_generated_description do
79: return_value = instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
80: end
81: return_value
82: end
# File lib/spec/example/example_methods.rb, line 67
67: def set_instance_variables_from_hash(instance_variables)
68: instance_variables.each do |variable_name, value|
69: unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].index(variable_name)
70: instance_variable_set variable_name, value
71: end
72: end
73: 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 93
93: def after_example
94: self.class.run_after_each(self)
95: verify_mocks_for_rspec
96: ensure
97: teardown_mocks_for_rspec
98: end