Skip to content

Commit

Permalink
Merge pull request resque#948 from sshingler/worker_test
Browse files Browse the repository at this point in the history
Adding a quick test for the string representations of a worker
  • Loading branch information
steveklabnik committed Apr 15, 2013
2 parents 8de228a + cbfd8a6 commit 447d772
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resque/worker_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/resque/worker_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'test_helper'

require 'resque/worker'
require 'socket'

describe Resque::Worker do
describe "#state" do
Expand All @@ -13,4 +14,16 @@
end
end
end

describe "#to_s, #inspect" 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
assert_equal "test.com:1234:{:queue=>\"foo\"}", worker.to_s
assert_equal "#<Worker test.com:1234:{:queue=>\"foo\"}>", worker.inspect
end
end
end
end
end

0 comments on commit 447d772

Please sign in to comment.