public
Last active

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.