How to unit test CGI methods?

I’ve added a number of methods to the CGI class that I’d like to unit
test, but CGI.new insists on prompting for parameter pairs, which
nullifies automation. Currently, I’m using an unelegant work-around by
keeping all the new methods in a CGIMethods class that I can test. I
then have a set of wrappers in the actual CGI extension. But it feels
wrong.

Is there any way to automate the parameter pairs for CGI.new?

···


David Heinemeier Hansson,
http://www.loudthinking.com/ – Thoughts for free
http://www.nextangle.com/ – Thoughts for hire

Have a look at the source of ruby-fcgi from RAA (lib/fcgi.rb, class FCGI).
It subclasses CGI to generate a new class like CGI but which gets its
parameters from elsewhere.

It would save hassle if CGI had a class method to do this though :slight_smile:

Cheers,

Brian.

···

On Wed, Jul 30, 2003 at 10:08:35PM +0900, David Heinemeier Hansson wrote:

I’ve added a number of methods to the CGI class that I’d like to unit
test, but CGI.new insists on prompting for parameter pairs, which
nullifies automation. Currently, I’m using an unelegant work-around by
keeping all the new methods in a CGIMethods class that I can test. I
then have a set of wrappers in the actual CGI extension. But it feels
wrong.

Is there any way to automate the parameter pairs for CGI.new?