Module: Greenbar::TimeSetup
- Includes:
- ClassMethodSetup, TestSetup
- Defined in:
- lib/greenbar/TimeSetup.rb
Overview
:include: doc/examples/TimeSetup.rb
Instance Method Summary collapse
-
#make_Time_now_return(time) ⇒ Object
Must be called before Time.new or Time.now if TimeSetup is being used.
-
#setup_mixin ⇒ Object
:startdoc:.
-
#teardown_mixin ⇒ Object
:nodoc:.
Methods included from ClassMethodSetup
#define_class_method, #replace_class_method, #replace_new
Methods included from TestSetup
included, #setup, #setup_mixins, #teardown, #teardown_mixins
Instance Method Details
#make_Time_now_return(time) ⇒ Object
Must be called before Time.new or Time.now if TimeSetup is being used.
54 55 56 |
# File 'lib/greenbar/TimeSetup.rb', line 54 def make_Time_now_return time Time.instance_variable_set '@now', time end |
#setup_mixin ⇒ Object
:startdoc:
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/greenbar/TimeSetup.rb', line 39 def setup_mixin #:nodoc: replace_class_method(Time, :now) { raise "Must use make_Time_now_return() when using TimeSetup." unless @now @now } replace_class_method(Time, :new) { Time.now } end |