forked from flores/moarcats-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.rb
executable file
·48 lines (38 loc) · 921 Bytes
/
tests.rb
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
ENV['RACK_ENV'] = 'test'
require 'fakeredis'
require File.dirname(__FILE__) + "/server.rb"
require 'test/unit'
require 'rack/test'
class EdgecatsTest < Test::Unit::TestCase
include Rack::Test::Methods
def app
Sinatra::Application
end
def test_random_cat
get '/'
assert last_response.ok?
assert last_response.headers.has_key?("X-Cat-Link")
end
def test_random_shortened_cat
get '/short'
assert last_response.ok?
end
def test_specific_cat
get '/cats/130621-33.gif'
assert last_response.ok?
assert_equal '510546', last_response.headers['Content-Length']
end
def test_all
get '/all'
assert last_response.ok?
end
def test_nonexistant_cat_redirect
get '/cats/nononononono.gif'
assert_equal 302, last_response.status
end
def test_favicon_404
get '/favicon.ico'
assert_equal 404, last_response.status
end
end