Methods
- __full_description
- after_example
- before_example
- description
- execute
- implementation_backtrace
- instance_variable_hash
- run_with_description_capturing
- set_instance_variables_from_hash
- violated
Included Modules
Constants
| PENDING_EXAMPLE_BLOCK | = | lambda { raise Spec::Example::ExamplePendingError.new("Not Yet Implemented") |
Public Instance methods
[ show source ]
# File lib/spec/example/example_methods.rb, line 67
67: def __full_description
68: "#{self.class.description} #{self.description}"
69: end
[ show source ]
# File lib/spec/example/example_methods.rb, line 63
63: def description
64: @_defined_description || @_matcher_description || "NO NAME"
65: end
[ show source ]
# 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
[ show source ]
# File lib/spec/example/example_methods.rb, line 89
89: def implementation_backtrace
90: eval("caller", @_implementation)
91: end
[ show source ]
# 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
[ show source ]
# File lib/spec/example/example_methods.rb, line 80
80: def run_with_description_capturing
81: begin
82: return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
83: ensure
84: @_matcher_description = Spec::Matchers.generated_description
85: Spec::Matchers.clear_generated_description
86: end
87: end
[ show source ]
# File lib/spec/example/example_methods.rb, line 71
71: def set_instance_variables_from_hash(ivars)
72: ivars.each do |variable_name, value|
73: # Ruby 1.9 requires variable.to_s on the next line
74: unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s)
75: instance_variable_set variable_name, value
76: end
77: end
78: end
[ show source ]
# File lib/spec/example/example_methods.rb, line 41
41: def violated(message="")
42: raise Spec::Expectations::ExpectationNotMetError.new(message)
43: end
Protected Instance methods
[ show source ]
# File lib/spec/example/example_methods.rb, line 102
102: def after_example
103: self.class.run_after_each(self)
104: verify_mocks_for_rspec
105: ensure
106: teardown_mocks_for_rspec
107: end
[ show source ]
# File lib/spec/example/example_methods.rb, line 97
97: def before_example
98: setup_mocks_for_rspec
99: self.class.run_before_each(self)
100: end