Skip to content

Commit 187c2f9

Browse files
gravisdefunkt
authored andcommitted
minimal unit testing resque-web.
a test_helper is available for plugin developers. refs resque#72
1 parent 48df4d0 commit 187c2f9

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

deps.rip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ git://github.com/brianmario/yajl-ruby.git 0.6.3
33
git://github.com/sinatra/sinatra.git 0.9.4
44
git://github.com/rack/rack.git 1.0
55
git://github.com/quirkey/vegas.git v0.1.2
6+
git://github.com/brynary/rack-test.git v0.5.3
67
rake

lib/resque/server/test_helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'rack/test'
2+
require 'resque/server'
3+
4+
module Resque
5+
module TestHelper
6+
class Test::Unit::TestCase
7+
include Rack::Test::Methods
8+
def app
9+
Resque::Server.new
10+
end
11+
12+
def self.should_respond_with_success
13+
test "should respond with success" do
14+
assert last_response.ok?
15+
end
16+
end
17+
end
18+
end
19+
end

test/resque-web_test.rb

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
require File.dirname(__FILE__) + '/test_helper'
2+
require 'resque/server/test_helper'
3+
4+
# Root path test
5+
context "on GET to /" do
6+
setup { get "/" }
7+
8+
test "redirect to overview" do
9+
follow_redirect!
10+
end
11+
end
12+
13+
# Global overview
14+
context "on GET to /overview" do
15+
setup { get "/overview" }
16+
17+
test "should at least display 'queues'" do
18+
assert last_response.body.include?('Queues')
19+
end
20+
end
21+
22+
# Working jobs
23+
context "on GET to /working" do
24+
setup { get "/working" }
25+
26+
should_respond_with_success
27+
end
28+
29+
# Failed
30+
context "on GET to /failed" do
31+
setup { get "/failed" }
32+
33+
should_respond_with_success
34+
end
35+
36+
# Stats
37+
context "on GET to /stats/resque" do
38+
setup { get "/stats/resque" }
39+
40+
should_respond_with_success
41+
end
42+
43+
context "on GET to /stats/redis" do
44+
setup { get "/stats/redis" }
45+
46+
should_respond_with_success
47+
end
48+
49+
context "on GET to /stats/resque" do
50+
setup { get "/stats/keys" }
51+
52+
should_respond_with_success
53+
end
54+

0 commit comments

Comments
 (0)