[rspec-users] Testing my scripts?
lists at ruby-forum.com
Wed Mar 4 00:35:19 EST 2009
Hello RSpec mailing list,
I have a question which I'm sure someone here has a "duh!" answer to. :P
A lot of the Ruby programming I do is around installing servers and
automating various tasks. The pattern I use goes as follows, I'm sure
you'll see where the gap is.
Write a failing test. Write enough Ruby code to make it pass. Continue
until I have a class (or set of classes) that solve my problem. So far,
I then need to put this code into a script so I can run it as part of
everyday automation. My approach so far has been to take green-light
code and plug it into the script so that when the script gets run, it
takes the arguments to the scripts and passes it to my tested code. The
script runs and does what its supposed to do; all is well.
Now -- there's a bug in my code somewhere, or I need to add something to
the code I've written to improve it. No problem initially. First, run
all tests. Green light, good. Write a failing test. Write enough Ruby
code to make it pass. Happy, happy.
Problem: the code in my script is not fixed! Running my spec suite does
not catch the fact that there's client code in my script using bad code.
So, my question is: how can I make sure that when I run my spec suite
that all the code in my scripts gets tested as well? I thought about
adding "--test" option to all my scripts, but that seems, well...just
not the right way to do it.
Anyone have any words of wisdom they'd like to share? Have I walked into
an antipattern here?
Posted via http://www.ruby-forum.com/.
More information about the rspec-users