Permalink
Browse files

updated count is returned in response body of POST

  • Loading branch information...
1 parent 739e1f7 commit c2a3993979f079ae5a41ce323e445407ca28af3e @stevenwilkin committed Feb 10, 2012
Showing with 8 additions and 3 deletions.
  1. +2 −2 coffee_tracker.rb
  2. +6 −1 test/api/{get_count_test.rb → get_and_update_count_test.rb}
View
@@ -19,7 +19,7 @@ class CoffeeTracker < Sinatra::Base
halt 403, {'Content-Type' => 'text/plain'}, 'Invalid API Key'
end
- $redis.hincrby 'coffee', Time.now.strftime("%Y%m%d"), 1
- 200
+ count = $redis.hincrby 'coffee', Time.now.strftime("%Y%m%d"), 1
+ [200, {'Content-Type' => 'text/plain'}, count.to_s]
end
end
@@ -2,7 +2,7 @@
require 'timecop'
-class IntegrationGetCountTest < Test::Unit::TestCase
+class ApiGetAndUpdateCountTest < Test::Unit::TestCase
include TestHelpers
def setup
@@ -29,6 +29,11 @@ def test_count_starts_at_zero
assert_equal '0', last_response.body, 'Should return zero'
end
+ def test_post_returns_updated_count
+ post '/api'
+ assert_equal '1', last_response.body, 'Should get updated count on POST'
+ end
+
def test_count_increases_after_post
post '/api'
get '/api'

0 comments on commit c2a3993

Please sign in to comment.