6

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.

John Topley
  • 113,588
  • 46
  • 195
  • 237
Chowlett
  • 45,935
  • 20
  • 116
  • 150

4 Answers4

5

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
  • 413
  • 3
  • 8
1

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
  • 25,824
  • 8
  • 48
  • 65
  • "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. – Chowlett Feb 17 '10 at 14:05
  • watir looks like it rocks, though. Good link! – Chowlett Feb 17 '10 at 14:06
  • 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 Feb 17 '10 at 14:07
  • Yep, but that's still too advanced for what I need now. Let me go and edit my Q for clarity. – Chowlett Feb 17 '10 at 14:08
1

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.

Community
  • 1
  • 1
David Schmitt
  • 58,259
  • 26
  • 121
  • 165
0

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
  • 113,588
  • 46
  • 195
  • 237
  • 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 – Chowlett Feb 17 '10 at 15:07
  • 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 Feb 17 '10 at 15:17