Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Workers need a #state.
In order for `resque list` to work, we need to know what state the workers have. This method was in the CLI, but didn't end up actually existing! Other changes: 1. So that we can run test/resque/worker_test.rb by itself, some lines were added so that worker.rb stands alone. 2. cli_test.rb was fixed up so that it doesn't mock things forever. This meant that I couldn't mock things in the other test... 3. Extracted worker construction to a method to make it easier to stub. I'm pretty sure this isn't threadsafe, though...
- Loading branch information
1 parent
ecb5343
commit 5963a64e9474eefc074f69149b1f12bcd60995b9
Showing
3 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| require 'test_helper' | ||
|
|
||
| require 'resque/worker' | ||
|
|
||
| describe Resque::Worker do | ||
| describe "#state" do | ||
| it "gives us the current state" do | ||
| worker = Resque::Worker.new :queue => "foo" | ||
| registry = MiniTest::Mock.new.expect(:state, "working") | ||
|
|
||
| worker.stub(:worker_registry, registry) do | ||
| assert_equal "working", worker.state | ||
| end | ||
| end | ||
| end | ||
| end |