Testing scripts

So in the past I’ve written a script that query’s a remote DB, takes
the data, validates it, then does some processing, producing a new file
with the data in a completely different format.

Since this is a script with it’s own set of methods, etc, how do I go
about testing the pieces parts?

It seems like it should be no different than doing the rails testing I
have been doing, but I think I’m missing something fundamental about
ruby.

What I’m doing now is wrapping the methods in a module, then including
the module at the top of the script.

I’m thinking this will allow me test those methods independently of the
script itself.

There still the problem of testing the logic of the script, but I’ll
keep banging away, and report back.

Are there other ways one might do testing against a script like this?

Mike B.

On Nov 13, 2007, at 7:45 pm, barsalou wrote:

What I’m doing now is wrapping the methods in a module, then including
the module at the top of the script.

Can you post some examples of the modules, classes and methods you have?

Every script I’ve written is basically just a little object-oriented
app that’s got a bit at the end to fire off some “main” class with the
command line args. Testing one is no different than testing, say, lib
code in Rails. Ideally you want each bit of functionality in a class
(and therefore file) of its own, so it can be tested in isolation.
But without seeing what you’ve got, it’s hard to guess where the
problem lies.

Ashley


blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home