Permalink
Browse files

tests for web_app routes

  • Loading branch information...
1 parent 49498b1 commit 4ddc42e691f3c7e2b4407eac0e9ec6bda4a22555 @agilion committed Feb 11, 2012
Showing with 48 additions and 0 deletions.
  1. +2 −0 models/game.rb
  2. +25 −0 test/web_app_test.rb
  3. +21 −0 web_app.rb
View
@@ -7,6 +7,8 @@ class Game < ActiveRecord::Base
def finalize!
self.winner = find_the_winner
self.loser = find_the_loser
+ self.completed = true
+ self.completed_at = Time.now
save
end
View
@@ -11,6 +11,31 @@ def app
def test_index
get '/'
assert_equal 'Hello World', last_response.body
+ assert last_response.ok?
end
+ def test_leaderboard
+ get '/leaderboard'
+ assert last_response.ok?
+ end
+
+ def test_player_profiles
+ get '/players/1'
+ assert last_response.ok?
+ end
+
+ def test_create_a_new_challenge
+ post '/games'
+ assert last_response.ok?
+ end
+
+ def test_updating_score_and_declaring_victory
+ put '/games/1'
+ assert last_response.ok?
+ end
+
+ def test_removing_a_challenge_or_game_from_the_platform
+ delete '/games/1'
+ assert last_response.ok?
+ end
end
View
@@ -1,6 +1,27 @@
class WebApp < Sinatra::Base
+ # Homepage
get '/' do
'Hello World'
end
+
+ # Show page for a player *Needs cool stats and competitive language!*
+ get '/players/:id' do
+ end
+
+ # An elaboration of the homepage but with all time statistics (Total num wins/losses, Greatest player on the platform ever)
+ get '/leaderboard' do
+ end
+
+ # Create a new challenge
+ post '/games' do
+ end
+
+ # Update score
+ put '/games/:id' do
+ end
+
+ # Remove an old game or challenge
+ delete '/games/:id' do
+ end
end

0 comments on commit 4ddc42e

Please sign in to comment.