Skip to content

Commit

Permalink
Testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
blovett committed Aug 5, 2015
1 parent 04a8e9f commit e060c97
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ gem 'puma', '~> 2.8.2'

group :development do
gem 'sinatra-reloader', '~> 1.0'
gem 'rack-test', '~> 0.6.3'
end
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ namespace :puma do
system("pumactl -F puma.rb status")
end
end

desc "Run tests"
task :test do
system("ruby ./tests.rb")
end
37 changes: 37 additions & 0 deletions tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env ruby

ENV['RACK_ENV'] = 'test'

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_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
end

0 comments on commit e060c97

Please sign in to comment.