test/functional/stats_controller_test.rb in resque-web-0.0.4 vs test/functional/stats_controller_test.rb in resque-web-0.0.5

- old
+ new

@@ -1,7 +1,70 @@ require 'test_helper' -class StatsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end +module ResqueWeb + class StatsControllerTest < ActionController::TestCase + include ControllerTestHelpers + + setup do + @routes = Engine.routes + end + + describe "GET /index" do + it "redirects to resque" do + visit(:index) + assert_redirected_to action: "resque" + end + end + + describe "GET /resque" do + it "renders the resque page" do + visit(:resque) + assert_template :resque + end + end + + describe "GET /resque.json" do + it "renders the resque page" do + visit(:resque, format: 'json') + assert_equal response.body, Hash[Resque.info.sort].to_json + end + end + + describe "GET /redis" do + it "renders the redis page" do + visit(:redis) + assert_template :redis + end + end + + describe "GET /redis.json" do + it "renders the redis page" do + expected = Resque.redis.info + Resque.redis.stubs(:info).returns(expected) + visit(:redis, format: 'json') + assert_equal response.body, Hash[expected.sort].to_json + end + end + + describe "GET /keys" do + it "renders the keys page" do + visit(:keys) + assert_template :keys + end + end + + describe "GET /keys/:id" do + it "renders the keys page" do + visit(:keys, id: "failed") + assert_template :key + end + end + + describe "GET /keys.json" do + it "renders the keys page" do + visit(:keys, format: 'json') + assert_equal response.body, Resque.keys.sort.to_json + end + end + + end end