-
Notifications
You must be signed in to change notification settings - Fork 110
Expand file tree
/
Copy pathexecutable_lookup_spec.rb
More file actions
63 lines (49 loc) · 1.79 KB
/
executable_lookup_spec.rb
File metadata and controls
63 lines (49 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require 'temporal/executable_lookup'
require 'temporal/concerns/executable'
describe Temporal::ExecutableLookup do
class TestClass
extend Temporal::Concerns::Executable
end
class MyDynamicActivity
extend Temporal::Concerns::Executable
end
class IllegalSecondDynamicActivity
extend Temporal::Concerns::Executable
end
describe '#add' do
it 'adds a class to the lookup map' do
subject.add('foo', TestClass)
expect(subject.send(:executables)).to eq('foo' => "TestClass")
end
end
describe '#add_dynamic' do
it 'fails on the second dynamic activity' do
subject.add_dynamic('MyDynamicActivity', MyDynamicActivity)
expect do
subject.add_dynamic('IllegalSecondDynamicActivity', IllegalSecondDynamicActivity)
end.to raise_error(Temporal::ExecutableLookup::SecondDynamicExecutableError)
end
end
describe '#find' do
before { subject.add('foo', TestClass) }
it 'returns a looked up class' do
expect(subject.find('foo')).to eq(TestClass)
end
it 'returns nil if there were no matches' do
expect(subject.find('bar')).to eq(nil)
end
it "still returns the class even it was unloaded and has a new object_id" do
original_object_id = stub_const('TestClass', Class.new).object_id
subject.add('foo', TestClass)
expected_class = stub_const('TestClass', Class.new)
expect(expected_class.object_id).not_to eq(original_object_id)
expect(subject.find('foo')).to be(expected_class)
end
it 'falls back to the dynamic executable' do
subject.add('TestClass', TestClass)
subject.add_dynamic('MyDynamicActivity', MyDynamicActivity)
expect(subject.find('TestClass')).to eq(TestClass)
expect(subject.find('SomethingElse')).to eq(MyDynamicActivity)
end
end
end