Module: Spec::Example::ExampleMethods
- Extended by:
- ModuleReopeningFix
- Included in:
- ExampleGroup, Test::Unit::TestCase
- Defined in:
- lib/mack/testing/rspec.rb,
lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb,
lib/gems/rspec-1.1.11/spec/spec/example/example_methods_spec.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes included from Matchers::ModuleMethods
Instance Method Summary collapse
- #__full_description ⇒ Object
- #description ⇒ Object
- #eval_block ⇒ Object
-
#eval_each_fail_fast(procs) ⇒ Object
:nodoc:.
-
#eval_each_fail_slow(procs) ⇒ Object
:nodoc:.
- #execute(options, instance_variables) ⇒ Object
- #implementation_backtrace ⇒ Object
- #instance_variable_hash ⇒ Object
- #options ⇒ Object
- #set_instance_variables_from_hash(ivars) ⇒ Object
- #violated(message = "") ⇒ Object
Methods included from ModuleReopeningFix
child_modules, include, included
Methods included from ModuleThatIsReopened
#module_that_is_reopened_method
Methods included from Pending
Methods included from Matchers
#be, #be_close, #change, #eql, #equal, #exception_from, #exist, #fail, #fail_with, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #smart_match, #throw_symbol
Methods included from Matchers::ModuleMethods
#clear_generated_description, #generated_description
Methods included from Mack::Testing::Helpers
#assigns, #clear_session, #cookies, #delete, #file_for_upload, #get, #in_session, #post, #put, #remote_test, #remove_cookie, #request, #response, #responses, #session, #set_cookie, #temp_app_config
Methods included from Mack::Routes::Urls
create_method, #redirect_html, #url_for_pattern
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Spec::Matchers
Instance Method Details
#__full_description ⇒ Object
67 68 69 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 67 def __full_description "#{self.class.description} #{self.description}" end |
#description ⇒ Object
59 60 61 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 59 def description @_defined_description || ::Spec::Matchers.generated_description || "NO NAME" end |
#eval_block ⇒ Object
12 13 14 15 16 |
# File 'lib/mack/testing/rspec.rb', line 12 def eval_block in_session do mack_eval_block end end |
#eval_each_fail_fast(procs) ⇒ Object
:nodoc:
41 42 43 44 45 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 41 def eval_each_fail_fast(procs) #:nodoc: procs.each do |proc| instance_eval(&proc) end end |
#eval_each_fail_slow(procs) ⇒ Object
:nodoc:
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 47 def eval_each_fail_slow(procs) #:nodoc: first_exception = nil procs.each do |proc| begin instance_eval(&proc) rescue Exception => e first_exception ||= e end end raise first_exception if first_exception end |
#execute(options, instance_variables) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 7 def execute(, instance_variables) .reporter.example_started(self) set_instance_variables_from_hash(instance_variables) execution_error = nil Timeout.timeout(.timeout) do begin before_each_example eval_block rescue Exception => e execution_error ||= e end begin after_each_example rescue Exception => e execution_error ||= e end end .reporter.example_finished(self, execution_error) success = execution_error.nil? || ExamplePendingError === execution_error end |
#implementation_backtrace ⇒ Object
84 85 86 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 84 def implementation_backtrace eval("caller", @_implementation) end |
#instance_variable_hash ⇒ Object
30 31 32 33 34 35 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 30 def instance_variable_hash instance_variables.inject({}) do |variable_hash, variable_name| variable_hash[variable_name] = instance_variable_get(variable_name) variable_hash end end |
#options ⇒ Object
63 64 65 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 63 def @_options end |
#set_instance_variables_from_hash(ivars) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 71 def set_instance_variables_from_hash(ivars) ivars.each do |variable_name, value| # Ruby 1.9 requires variable.to_s on the next line unless ['@_implementation', '@_defined_description', '@_matcher_description', '@method_name'].include?(variable_name.to_s) instance_variable_set variable_name, value end end end |
#violated(message = "") ⇒ Object
37 38 39 |
# File 'lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb', line 37 def violated(="") raise Spec::Expectations::ExpectationNotMetError.new() end |