Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test Ruby scripts which offer functionality between runs?

Tags:

ruby

testunit

What's a good method for unit testing which test a script's ability to maintain correct data between executions--after a script is terminated with Ctrl-C and then re-run? Are there any tests for existing modules or scripts that do something similar that could be reviewed for best practices?

like image 649
sutch Avatar asked Aug 20 '11 17:08

sutch


1 Answers

Use library like http://avdi.org/devblog/2010/07/19/greenletters-painless-automation-and-testing-for-command-line-applications/ or expect, run, terminate and rerun your program, and check if it behaves correctly. Good practice is to design program as independent modules, each well tested, to minimize integration test in console.

like image 110
Sławosz Avatar answered Nov 15 '22 06:11

Sławosz