Topic: Unit test controller with fake CGI params
Hiya,
Im trying to unit test an app against a browser that works inside a game. The browser itself works with html 1.0 standard at the moment so its faily simple, however in its header it sends a few variable that relate to the game, like the username. in PHP it would be something like
echo $_SERVER['GAME_USERNAME']
Now what I have inmy controller is this
u = User.new(
:name => cgi.params['GAME_USERNAME'],
:last_seen => Time.now.gmtime
}
Question 1 is do I need the cgi. bit or can I jusat call params?
So in my test for this controller I need to fake that CGI param, how would I go about doing that, would it be like this
(IGB stands for In Game Browser)
def test_user_from_igb
get :info, :game_username => 'Fred'
end
Im coding this a bit blind as the spec for the IGB has been written but not the actual IGB itself so I cant test it in the realworld for a bit. So kinda want to fake it just for my own sanity so I can get this thing coded!
Thanks
- Chris