Skip to content

Instantly share code, notes, and snippets.

@petrblaho
Created August 22, 2010 18:20
Show Gist options
  • Save petrblaho/544095 to your computer and use it in GitHub Desktop.
Save petrblaho/544095 to your computer and use it in GitHub Desktop.
require 'rubygems'
# http://github.com/archiloque/rest-client
require 'rest_client'
# STARTED
# set game with hash_code 'game_hash123' as started
RestClient.post "http://localhost:3000/games/game_hash123/started", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ' }, :content_type => :json, :accept => :json
# INTERRUPTED
# set game with hash_code 'game_hash123' as interrupted with one player as interruptee
# use string with player hash
RestClient.post "http://localhost:3000/games/game_hash123/interrupted", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ', 'game[users]' => 'user111' }, :content_type => :json, :accept => :json
# use array with string with player hash
RestClient.post "http://localhost:3000/games/game_hash123/interrupted", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ', 'game[users]' => ['user111'] }, :content_type => :json, :accept => :json
# set game with hash_code 'game_hash123' as interrupted with both players as interruptee
response = RestClient.post "http://localhost:3000/games/game_hash123/interrupted", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ', 'game[users]' => ['user111', 'user222'] }, :content_type => :json, :accept => :json
# FINISHED
# set game with hash_code 'game_hash123' as finished
# use string or array of strings for winners, loosers, draws
response = RestClient.post "http://localhost:3000/games/game_hash123/finished", { '_method' => 'put', 'user_credentials' => 'xH31MpM8xSff3em8LwGJ', 'game[winners]' => ['admin'], 'game[loosers]' => ['tester'] }, :content_type => :json, :accept => :json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment