我正在制作一个名为“图书俱乐部”的应用程序。系统中将有很多书和票。每个月,在本月的第一天,我需要系统自动将具有最高票数的书籍推荐为“本月书”。推销一本书并确保每月只有一本书的逻辑已经实施。Rails应用程序需要每月执行一次任务
book.promote!
可爱吧?
我有我的测试情况下hurr
Given the following books exist:
| title | author | year_published | votes | created_at |
| Lord of the Flies | William Golding | 1954 | 18 | January 12, 2010 |
| The Virgin Suicides | Jeffrey Eugenides | 1993 | 12 | February 15, 2010 |
| Island | Richard Laymon | 1991 | 6 | November 22, 2009 |
And the book "Lord of the Flies" is the current book of the month
And the date is "February 24, 2010"
Then the book "Lord of the Flies" should be the current book of the month
When the date is "March 1, 2010"
And I am on the home page
Then I should see "This Month's Book of the Month Club Book"
And I should see "The Virgin Suicides"
And the book "The Virgin Suicides" should be the current book of the month
And the book "Lord of the Flies" should not be the current book of the month
And the book "Island" should not be the current book of the month
而我试图让通过。
所以问题是,我该如何最好地实现自动的,每月一次的更新,可以通过这种情况来测试?
克朗对我的口味有点过于sl。。我想要一个更便携的解决方案。
delayed_job/Resque对于这种情况似乎有点过重。此外,我还不确定如何让他们每月运行一次工作。
只是寻找一个简单,但强大的TESTABLE解决方案。
欢呼,一如既往!
如果你可以解释为什么'cron'对你来说太sl I,我可以建议更好的选择。 – Swanand 2010-12-15 04:13:41
要使用cron,我必须在我的测试套件中开始做出假设。我可以完成cron作业调用并测试的rake任务,但是我仍然假定cron作业将在我的环境中设置。也许我在那个时候有点儿迂腐,但它不能覆盖这个系统的关键方面并不合适。 – drmanitoba 2010-12-15 15:37:18