File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 27
27
28
28
describe ".worker_id" do
29
29
subject { described_class . send ( :worker_id ) }
30
- before do
31
- allow ( described_class ) . to receive ( :program_name ) . and_return ( program_name )
30
+ around ( :example ) do |ex |
31
+ old_name = $PROGRAM_NAME
32
+ $PROGRAM_NAME = program_name
33
+ ex . run
34
+ $PROGRAM_NAME = old_name
32
35
end
33
36
34
37
context "when program_name matches pitchfork worker" do
42
45
43
46
it { is_expected . to eq ( "pitchfork_1" ) }
44
47
end
48
+
49
+ context "when program_name doesn't match pitchfork worker" do
50
+ let ( :program_name ) { "something else" }
51
+
52
+ let ( :worker ) { double ( "Pitchfork::Worker" , nr : 2 ) }
53
+
54
+ before do
55
+ stub_const ( "Pitchfork::Worker" , Class . new )
56
+ allow ( ObjectSpace ) . to receive ( :each_object ) . with ( Pitchfork ::Worker ) . and_return ( [ worker ] )
57
+ end
58
+
59
+ it { is_expected . to eq ( "pitchfork_2" ) }
60
+ end
45
61
end
46
62
end
47
63
You can’t perform that action at this time.
0 commit comments