Module Spec::Example::ExampleMethods
In: lib/spec/example/example_methods.rb

Methods

Included Modules

ModuleInclusionWarnings Matchers Pending

Constants

PENDING_EXAMPLE_BLOCK = lambda { raise Spec::Example::ExamplePendingError.new("Not Yet Implemented")

Public Instance methods

[Source]

    # File lib/spec/example/example_methods.rb, line 69
69:       def __full_description
70:         "#{self.class.description} #{self.description}"
71:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 65
65:       def description
66:         @_defined_description || @_matcher_description || "NO NAME"
67:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 13
13:       def execute(options, instance_variables)
14:         options.reporter.example_started(self)
15:         set_instance_variables_from_hash(instance_variables)
16:         
17:         execution_error = nil
18:         Timeout.timeout(options.timeout) do
19:           begin
20:             before_example
21:             run_with_description_capturing
22:           rescue Exception => e
23:             execution_error ||= e
24:           end
25:           begin
26:             after_example
27:           rescue Exception => e
28:             execution_error ||= e
29:           end
30:         end
31: 
32:         options.reporter.example_finished(self, execution_error)
33:         success = execution_error.nil? || ExamplePendingError === execution_error
34:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 91
91:       def implementation_backtrace
92:         eval("caller", @_implementation)
93:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 36
36:       def instance_variable_hash
37:         instance_variables.inject({}) do |variable_hash, variable_name|
38:           variable_hash[variable_name] = instance_variable_get(variable_name)
39:           variable_hash
40:         end
41:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 82
82:       def run_with_description_capturing
83:         begin
84:           return instance_eval(&(@_implementation || PENDING_EXAMPLE_BLOCK))
85:         ensure
86:           @_matcher_description = Spec::Matchers.generated_description
87:           Spec::Matchers.clear_generated_description
88:         end
89:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 73
73:       def set_instance_variables_from_hash(ivars)
74:         ivars.each do |variable_name, value|
75:           # Ruby 1.9 requires variable.to_s on the next line
76:           unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s)
77:             instance_variable_set variable_name, value
78:           end
79:         end
80:       end

[Source]

    # File lib/spec/example/example_methods.rb, line 43
43:       def violated(message="")
44:         raise Spec::Expectations::ExpectationNotMetError.new(message)
45:       end

Protected Instance methods

[Source]

     # File lib/spec/example/example_methods.rb, line 104
104:       def after_example
105:         self.class.run_after_each(self)
106:         verify_mocks_for_rspec
107:       ensure
108:         teardown_mocks_for_rspec
109:       end

[Source]

     # File lib/spec/example/example_methods.rb, line 99
 99:       def before_example
100:         setup_mocks_for_rspec
101:         self.class.run_before_each(self)
102:       end

[Validate]