# \[ANN\] RailsCron 0.2.2, please update

**URL:** <https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479>\
**Category:** Rails\
**Created:** [February 7, 2006, 4:54am UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479 "2006-02-07T04:54:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [February 7, 2006, 4:54am UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479/1 "2006-02-07T04:54:31Z")

</div>

I updated RailsCron to fix some threading issues with ActiveRecord.  
Please update if you were on 0.2.1. Also, I am still working on a  
good unit test strategy (its tricky because I would think that the  
tests must occur over a lot of time), but haven’t had/made time to  
give it its due. If you have suggestions, please let me know.

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261

---

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [February 7, 2006, 5:18am UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479/2 "2006-02-07T05:18:42Z")

</div>

On 2/6/06, Kyle M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I updated RailsCron to fix some threading issues with ActiveRecord.  
> Please update if you were on 0.2.1. Also, I am still working on a  
> good unit test strategy (its tricky because I would think that the  
> tests must occur over a lot of time), but haven’t had/made time to  
> give it its due. If you have suggestions, please let me know.

Saw a lot of this, on a larger scale, while testing systems prior to  
Y2K.  
How about refactoring lines like this:  
now = Time.now.to\_i  
…to be method calls to a stub, rather than bare Time.now?  
Then, during test setup, you can push in a different object that  
returns times you specify in advance.

I suppose you could also do this, but it’s bad scary:  
irb(main):001:0\> class Time  
irb(main):002:1\> class \<\< self  
irb(main):003:2\> attr\_writer :fake\_time  
irb(main):004:2\> alias\_method :right\_now, :now  
irb(main):005:2\> end  
irb(main):006:1\>  
irb(main):007:1\* def self.now  
irb(main):008:2\> @fake\_time || self.right\_now  
irb(main):009:2\> end  
irb(main):010:1\> end  
=\> nil  
irb(main):011:0\> t = Time.now - 800000  
=\> Sat Jan 28 17:01:44 Eastern Standard Time 2006  
irb(main):012:0\> Time.fake\_time = t  
=\> Sat Jan 28 17:01:44 Eastern Standard Time 2006  
irb(main):013:0\> Time.now  
=\> Sat Jan 28 17:01:44 Eastern Standard Time 2006  
irb(main):014:0\> Time.fake\_time = nil  
=\> nil  
irb(main):015:0\> Time.now  
=\> Mon Feb 06 23:15:42 Eastern Standard Time 2006  
irb(main):016:0\>

It’s actually kinda insane that you can do that. I like it.

---

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [February 7, 2006, 11:00am UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479/3 "2006-02-07T11:00:50Z")

</div>

Hi Kyle

I have no experience (yet!) with unit testing of “scheduled things” in  
ruby  
and ror, but on other platforms, I’m often using a dedicated class to  
provide the time to other classes. I do this in an explicit way (such as  
passing the instance of time provider at construction time) rather than  
implicit (that would be the more scary way Wilson describes!).

When I write the corresponding test, I pass a mocked version of this  
class  
instead, and simulate the change of time on the time provider, then  
check  
how the system under test reacts.

This way the test doesn’t have to run a long time.

Have a look there  
[http://www.pragmaticprogrammer.com/articles/may\_02\_mock.pdf](http://www.pragmaticprogrammer.com/articles/may_02_mock.pdf)

The paragraph entitled “mock objects” lists the most common cases where  
it’s  
relevant to use a mock object.

HTH

## Thibaut

[blog] [http://www.dotnetguru2.org/tbarrere](http://www.dotnetguru2.org/tbarrere)

---

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [February 7, 2006, 2:20pm UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479/4 "2006-02-07T14:20:47Z")

</div>

On Feb 6, 2006, at 10:52 PM, Kyle M. wrote:

> I updated RailsCron to fix some threading issues with ActiveRecord.  
> Please update if you were on 0.2.1. Also, I am still working on a  
> good unit test strategy (its tricky because I would think that the  
> tests must occur over a lot of time), but haven’t had/made time to  
> give it its due. If you have suggestions, please let me know.

Are you still at [http://opensvn.csie.org/rails\_cron/trunk](http://opensvn.csie.org/rails_cron/trunk)?

I just svn up’ped and didn’t get any changes. (Revision: 5)

> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)  
> –  
> Daryl

“We want great men who, when fortune frowns, will not be discouraged.”  
– Colonel Henry Knox, 1776

---

<div class="post-metadata">

**Author:** ![kylemathews](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/51bf81/32.png) [@kylemathews](https://www.ruby-forum.com/u/kylemathews)\
**Post date:** [February 7, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/ann-railscron-0-2-2-please-update/53479/5 "2006-02-07T19:25:38Z")

</div>

On 2/7/06, Daryl R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > * * *
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

I moved it to [svn.kylemaxwell.com/rails\_cron/trunk](http://svn.kylemaxwell.com/rails_cron/trunk) … I need to pull  
down the csie repository.

–  
Kyle M.  
Chief Technologist  
E Factor Media // FN Interactive  
removed\_email\_address@domain.invalid  
1-866-263-3261
