I have a task that runs frequently in order to get/import data from another system. Because of this I wanted to know which is the best way to test tasks in order to create the tests needed. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110802/315d630f/attachment.html>
On Aug 2, 2011, at 4:41 PM, Piter Fcbk wrote:> I have a task that runs frequently in order to get/import data from another system. > Because of this I wanted to know which is the best way to test tasks in order to create the tests needed. > > Thanks in advance.I write simple objects that implement the behavior I want. Then I write rake tasks that instantiate and use those objects. I don''t write automated tests for the tasks because they are thin layers over my well-tested objects. Pat
On Tue, Aug 2, 2011 at 4:41 PM, Piter Fcbk <piter.fcbk at gmail.com> wrote:> I have a task that runs frequently in order to get/import data from another > system. > Because of this I wanted to know which is the best way to test tasks in > order to create the tests needed. > > Thanks in advance. >Assuming you are asking about rake tasks... I typically extract the body of the task into a method and then test that method. This typically leaves the rake task very thin and I do not worry about testing the task itself. Best, Michael Guterl
You are right, I''m talking about rake task. So the idea is to make an Importer object, do the unit test for that object and then the task just calls the methods of the objects right? Thanks a lot for the help, really appreciate it. On Tue, Aug 2, 2011 at 6:31 PM, Pat Maddox <patmaddox at me.com> wrote:> On Aug 2, 2011, at 4:41 PM, Piter Fcbk wrote: > > > I have a task that runs frequently in order to get/import data from > another system. > > Because of this I wanted to know which is the best way to test tasks in > order to create the tests needed. > > > > Thanks in advance. > > I write simple objects that implement the behavior I want. Then I write > rake tasks that instantiate and use those objects. I don''t write automated > tests for the tasks because they are thin layers over my well-tested > objects. > > Pat > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110802/a4921785/attachment.html>
On Tue, Aug 2, 2011 at 5:52 PM, Piter Fcbk <piter.fcbk at gmail.com> wrote:> You are right, I''m talking about rake task. > So the idea is to make an Importer object, do the unit test for that object > and then the task just calls the methods of the objects right? > > Thanks a lot for the help, really appreciate it. > > > On Tue, Aug 2, 2011 at 6:31 PM, Pat Maddox <patmaddox at me.com> wrote: > >> On Aug 2, 2011, at 4:41 PM, Piter Fcbk wrote: >> >> > I have a task that runs frequently in order to get/import data from >> another system. >> > Because of this I wanted to know which is the best way to test tasks in >> order to create the tests needed. >> > >> > Thanks in advance. >> >> I write simple objects that implement the behavior I want. Then I write >> rake tasks that instantiate and use those objects. I don''t write automated >> tests for the tasks because they are thin layers over my well-tested >> objects. >> >> Pat >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersnamespace :importer do task :import do Importer.import end end describe Importer do describe ''.import'' do ... -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110802/f1e8d394/attachment.html>