Skip to content

Commit

Permalink
minimal unit testing resque-web.
Browse files Browse the repository at this point in the history
a test_helper is available for plugin developers.
refs resque#72
  • Loading branch information
gravis authored and defunkt committed Mar 18, 2010
1 parent 48df4d0 commit 187c2f9
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions deps.rip
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ git://github.com/brianmario/yajl-ruby.git 0.6.3
git://github.com/sinatra/sinatra.git 0.9.4
git://github.com/rack/rack.git 1.0
git://github.com/quirkey/vegas.git v0.1.2
git://github.com/brynary/rack-test.git v0.5.3
rake
19 changes: 19 additions & 0 deletions lib/resque/server/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'rack/test'
require 'resque/server'

module Resque
module TestHelper
class Test::Unit::TestCase
include Rack::Test::Methods
def app
Resque::Server.new
end

def self.should_respond_with_success
test "should respond with success" do
assert last_response.ok?
end
end
end
end
end
54 changes: 54 additions & 0 deletions test/resque-web_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
require File.dirname(__FILE__) + '/test_helper'
require 'resque/server/test_helper'

# Root path test
context "on GET to /" do
setup { get "/" }

test "redirect to overview" do
follow_redirect!
end
end

# Global overview
context "on GET to /overview" do
setup { get "/overview" }

test "should at least display 'queues'" do
assert last_response.body.include?('Queues')
end
end

# Working jobs
context "on GET to /working" do
setup { get "/working" }

should_respond_with_success
end

# Failed
context "on GET to /failed" do
setup { get "/failed" }

should_respond_with_success
end

# Stats
context "on GET to /stats/resque" do
setup { get "/stats/resque" }

should_respond_with_success
end

context "on GET to /stats/redis" do
setup { get "/stats/redis" }

should_respond_with_success
end

context "on GET to /stats/resque" do
setup { get "/stats/keys" }

should_respond_with_success
end

0 comments on commit 187c2f9

Please sign in to comment.