Module: LiveUnit
- Extended by:
- LiveUnit
- Included in:
- LiveUnit
- Defined in:
- lib/liveunit.rb,
lib/liveunit/loader.rb,
lib/liveunit/reporter.rb,
lib/liveunit/testcase.rb,
lib/liveunit/evaluator.rb,
lib/liveunit/print_reporter.rb
Overview
Core parent module, everything lives inside it
Defined Under Namespace
Classes: Evaluator, Loader, PrintReporter, Reporter, TestCase
Class Method Summary collapse
-
.included(klass) ⇒ Object
inject the required liveunit’s methods when the module is included.
Instance Method Summary collapse
-
#track_methods(obj, first_pass) ⇒ Object
tracks all the object’s methods if we have already modified the class, don’t redefine again and just create the callbacks.
Class Method Details
.included(klass) ⇒ Object
inject the required liveunit’s methods when the module is included
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/liveunit.rb', line 12 def self.included(klass) unless klass.instance_methods.include?(:evaluator) body = Proc.new { |reporter=LiveUnit::PrintReporter| @_liveunit_evaluator = LiveUnit::Evaluator.new(self) if self.methods.select{|m| m.match(/^liveunit/)}.empty? LiveUnit.track_methods(self, first_pass=true) else LiveUnit.track_methods(self, first_pass=false) end @_liveunit_reporter = @_liveunit_evaluator.create_reporter(klass, reporter) LiveUnit::Loader.new.require_directory("./livetest") } klass.send(:define_method, :evaluate_me, body) body = Proc.new { @_liveunit_evaluator } klass.send(:define_method, :evaluator, body) body = Proc.new { @_liveunit_reporter } klass.send(:define_method, :reporter, body) end end |
Instance Method Details
#track_methods(obj, first_pass) ⇒ Object
tracks all the object’s methods if we have already modified the class, don’t redefine again and just create the callbacks
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/liveunit.rb', line 35 def track_methods(obj, first_pass) my_methods = obj.class.instance_methods(false) my_methods.delete(:evaluate_me) my_methods.delete(:evaluator) my_methods.delete(:reporter) my_methods.delete(:loader) if first_pass my_methods.each do |m| redefine(obj, m) create_callbacks_for(obj, m) end else my_methods.each do |m| create_callbacks_for(obj, m) end end end |