From: Wakou Aoyama Date: 2002-03-26T05:05:37+09:00 Subject: Re: CGI testing On Mon, Mar 25, 2002 at 09:51:13AM +0900, Norman Makoto Su wrote: > Is there a way to create a CGI object with its key, value parameters already > initialized? This is for testing purposes. I know there is an "offline mode", > but I don't want to have to type in the values everytime for testing. I was > considering using mock objects for testing, but it is kind of tedious to write > down the exact order (via __next) for each access to the CGI object's > parameters. $ cat test.rb ENV['REQUEST_METHOD'] = 'GET' ENV['QUERY_STRING'] = 'query1=%7Evalue1&query2=value1&query2=value2' require "cgi" cgi = CGI.new p cgi.params $ ruby test.rb {"query2"=>["value1", "value2"], "query1"=>["~value1"]} or $ cat test.rb require "cgi" cgi = CGI.new p cgi.params $ export REQUEST_METHOD=GET $ export QUERY_STRING='query1=%7Evalue1&query2=value1&query2=value2' $ ruby test.rb {"query2"=>["value1", "value2"], "query1"=>["~value1"]} -- Wakou Aoyama