Module: Greenbar::DateSetup

Includes:
ClassMethodSetup, TestSetup
Defined in:
lib/greenbar/DateSetup.rb

Instance Method Summary collapse

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_Date_today_return(date) ⇒ Object

Sets the Date to be returned for Date.today Must be called before Date.today if DateSetup is being used.



51
52
53
# File 'lib/greenbar/DateSetup.rb', line 51

def make_Date_today_return date
  Date.instance_variable_set '@today', date
end

#setup_mixinObject

:nodoc:



39
40
41
42
43
44
45
# File 'lib/greenbar/DateSetup.rb', line 39

def setup_mixin #:nodoc:
  replace_class_method(Date, :today) {
    raise "Must use make_Date_today_return() when using DateSetup." unless defined? @today
    @today
  }

end

#teardown_mixinObject

:nodoc:



55
56
57
# File 'lib/greenbar/DateSetup.rb', line 55

def teardown_mixin #:nodoc:
  Date.instance_eval {remove_instance_variable '@today'} if Date.instance_variables.include?('@today')
end