Ashley said:
Message: 7 Date: Tue, 13 Nov 2007 20:43:53 +0000 From: Ashley Moran <[EMAIL PROTECTED]> Subject: Re: [rspec-users] testing scripts To: rspec-users <[email protected]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes 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 ------ Ashley, I think what I've come to realize is that I need to refactor what I've done. A quick example would be: def exists?(device) # do device validation end device = Device.find(1) if exists?(device) then # do my thing end I realize that exists? should really be part of Device and doing testing on this script is helping me look at the objects differently and I'm starting to refactor. So I think my initial problem with testing my script is that it's not really OO in the first place. You've confirmed for me what I had been thinking and I'll work to that end. Thanks for the feedback. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. _______________________________________________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
