From 97d576cb93bf6d59598a8ba41d083ba72b95fd3a Mon Sep 17 00:00:00 2001 From: Steven Shingler Date: Mon, 15 Apr 2013 23:39:28 +0100 Subject: [PATCH 1/2] Adding a to_s and inspect test to worker. --- lib/resque/worker_registry.rb | 2 +- test/resque/worker_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/resque/worker_registry.rb b/lib/resque/worker_registry.rb index 948eb3a6d..d41b2ee0b 100644 --- a/lib/resque/worker_registry.rb +++ b/lib/resque/worker_registry.rb @@ -3,7 +3,7 @@ module Resque class WorkerRegistry REDIS_WORKERS_KEY = :workers REDIS_SINGLE_WORKER_KEY = :worker - + # Direct access to the Redis instance. def redis Resque.redis diff --git a/test/resque/worker_test.rb b/test/resque/worker_test.rb index 94038eec7..1f96b9641 100644 --- a/test/resque/worker_test.rb +++ b/test/resque/worker_test.rb @@ -1,6 +1,7 @@ require 'test_helper' require 'resque/worker' +require 'socket' describe Resque::Worker do describe "#state" do @@ -13,4 +14,16 @@ end end end + + describe "#to_s, #inspect" do + it "give us string representations of a worker" do + worker = Resque::Worker.new(:queue => "foo") + Socket.stub(:gethostname, "test.com") do + worker.stub(:pid, "1234") do + assert_equal "test.com:1234:{:queue=>\"foo\"}", worker.to_s + assert_equal "#\"foo\"}>", worker.inspect + end + end + end + end end From cbfd8a6a0f1e6eabe4b1e69f64dc72a61f99717d Mon Sep 17 00:00:00 2001 From: Steven Shingler Date: Mon, 15 Apr 2013 23:41:22 +0100 Subject: [PATCH 2/2] typo. --- test/resque/worker_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/resque/worker_test.rb b/test/resque/worker_test.rb index 1f96b9641..d6f7a7bc2 100644 --- a/test/resque/worker_test.rb +++ b/test/resque/worker_test.rb @@ -16,7 +16,7 @@ end describe "#to_s, #inspect" do - it "give us string representations of a worker" do + it "gives us string representations of a worker" do worker = Resque::Worker.new(:queue => "foo") Socket.stub(:gethostname, "test.com") do worker.stub(:pid, "1234") do