I'm relatively new to Ruby, but learning fast. As an exercise, I'm porting
a family of untested bash scripts to Ruby, and I'm running into some things
that I'm not sure how best to test.
I know how to write the code, but I want to be able to write it test-first,
and I'm not sure of the best way to test it.
I'm using minitest, if that makes a difference.
1. Compute the total size of a directory and its contents (bash script uses
"du" for this)
2. Make a clean copy of a directory and its contents, removing any version
control directories (.svn, .git)
3. Shell out to run a few commands using fakeroot. Bonus points if there's
a way to test that the commands have the desired effects.
4. Get a list of files matching a given pattern on a remote server (using
ssh).
5. Copy a file up to a remote server (using scp).
6. Run a script on a remote server (again, ssh).
I know I could write some mock-heavy tests here to make sure my program is
running the right shell commands and such, but that doesn't seem to fully
test that the program does what I want.
How would you approach writing tests for scenarios like these?
Thanks,
Randy
···
--
Randy Coulman
rcoulman@gmail.com
Twitter: @randycoulman