views:

260

answers:

4

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it.

When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing a 2-player game by having the app open in FireFox and Internet Explorer at the same time.

Before I go off and download Chrome in order to test a third player... is there an easier way of doing this?

Edit: To clarify, I'm not yet at the stage where I want to run automated tests to see if it breaks. I'm at the stage where I want to be able to hack the back-end db, then refresh the page and see how it looks now, or click a button to see the (usually) failure response, or whether the behaviour is looking right.

+1  A: 

Automate it!


You really don't want to be manually testing this. You could use a Ruby script with the curl libs to generate the 'moves' and manage the response including the session cookie.
As a teaser, see this snippet from the API docs, sounds like it would help you..

easy.cookiejar = "cookiejar.file" => "pwd string"

Set a cookiejar file to use for this Curl::Easy instance. 
This file will be used to persist cookies. 
Chris McCauley
or even better, use http://watir.com/ if you're already using ruby!
David Schmitt
"Testing" is perhaps the wrong word. Or at the wrong scope. I'm not taking a semi-finished app and making sure it doesn't break; I'm taking my pretty half-baked work-in-progress, and making sure it does roughly what I want it to.
Chris
watir looks like it rocks, though. Good link!
Chris
The great thing is that it's easy to hack it together - you could have a couple of scripts play against each other
Chris McCauley
Yep, but that's still too advanced for what I need now. Let me go and edit my Q for clarity.
Chris
+1  A: 

Use http://watir.com/ to create ruby scripts exercising your game.

Use multiple Watir::Browser instances to run multiple browsers.

Use firefox' profiles and -no-remote switch to keep them separated. See also this question.

David Schmitt
Ah, FF profiles. Yes, that'd do it.
Chris
A: 

Rather than opening a new tab, create a new window in your Web browser. The new window will have its own session. This works for Internet Explorer, but not for Firefox. I haven't tested it in the WebKit based browsers.

John Topley
Not true in Firefox. I can make it work in IE (File-> New Session), which is good to know, but I might go for the FF Profiles route in order to get Firebug available
Chris
You're right, it's a while since I did it so my memory was hazy on Firefox. I've edited my answer.
John Topley
+3  A: 

You can run Firefox with multiple profiles. From a command line go to the directory Firefox is installed in and run firefox -P. Create a profile for every instance that you want to run. Close the profile manager, then for each profile run firefox -no-remote -P "profile name". You can run as many instances of Firefox as you want, and each one runs with an independent profile and thus independent session.

JamesH