bumbleworks 0.0.74 → 0.0.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -1
- data/.ruby-version +1 -1
- data/bumbleworks.gemspec +2 -2
- data/lib/bumbleworks.rb +1 -0
- data/lib/bumbleworks/expression.rb +12 -1
- data/lib/bumbleworks/process.rb +10 -0
- data/lib/bumbleworks/process/error_record.rb +14 -0
- data/lib/bumbleworks/schedule.rb +58 -0
- data/lib/bumbleworks/task.rb +2 -1
- data/lib/bumbleworks/task/finder.rb +4 -0
- data/lib/bumbleworks/version.rb +1 -1
- data/lib/bumbleworks/workitem.rb +4 -0
- data/spec/fixtures/schedules.rb +40 -0
- data/spec/integration/entity_spec.rb +7 -7
- data/spec/integration/example_configurations_spec.rb +5 -5
- data/spec/integration/history_storage_spec.rb +9 -9
- data/spec/integration/sample_application_spec.rb +15 -15
- data/spec/lib/bumbleworks/configuration_spec.rb +52 -52
- data/spec/lib/bumbleworks/entity_spec.rb +66 -68
- data/spec/lib/bumbleworks/error_handler_spec.rb +1 -1
- data/spec/lib/bumbleworks/error_logger_spec.rb +5 -5
- data/spec/lib/bumbleworks/expression_spec.rb +34 -12
- data/spec/lib/bumbleworks/hash_storage_spec.rb +2 -2
- data/spec/lib/bumbleworks/participant/base_spec.rb +1 -1
- data/spec/lib/bumbleworks/participant/entity_interactor_spec.rb +20 -20
- data/spec/lib/bumbleworks/participant/error_dispatcher_spec.rb +3 -3
- data/spec/lib/bumbleworks/participant/local_participant_spec.rb +1 -1
- data/spec/lib/bumbleworks/participant_registration_spec.rb +4 -4
- data/spec/lib/bumbleworks/process/error_record_spec.rb +13 -0
- data/spec/lib/bumbleworks/process_definition_spec.rb +30 -24
- data/spec/lib/bumbleworks/process_spec.rb +86 -54
- data/spec/lib/bumbleworks/ruote/exp/broadcast_event_expression_spec.rb +2 -2
- data/spec/lib/bumbleworks/ruote/exp/wait_for_event_expression_spec.rb +4 -4
- data/spec/lib/bumbleworks/ruote_spec.rb +73 -71
- data/spec/lib/bumbleworks/schedule_spec.rb +124 -0
- data/spec/lib/bumbleworks/simple_logger_spec.rb +8 -8
- data/spec/lib/bumbleworks/storage_adapter_spec.rb +16 -16
- data/spec/lib/bumbleworks/support_spec.rb +23 -19
- data/spec/lib/bumbleworks/task/finder_spec.rb +46 -46
- data/spec/lib/bumbleworks/task_spec.rb +188 -167
- data/spec/lib/bumbleworks/tracker_spec.rb +41 -42
- data/spec/lib/bumbleworks/tree_builder_spec.rb +9 -7
- data/spec/lib/bumbleworks/user_spec.rb +35 -35
- data/spec/lib/bumbleworks/workitem_entity_storage_spec.rb +5 -5
- data/spec/lib/bumbleworks/workitem_spec.rb +28 -17
- data/spec/lib/bumbleworks_spec.rb +57 -51
- data/spec/spec_helper.rb +0 -1
- data/spec/support/shared_examples.rb +3 -3
- metadata +35 -54
@@ -1,22 +1,21 @@
|
|
1
|
-
require File.expand_path(File.join(fixtures_path, 'entities', 'rainbow_loom'))
|
2
1
|
require File.expand_path(File.join(fixtures_path, 'trackers'))
|
3
2
|
|
4
3
|
describe Bumbleworks::Tracker do
|
5
4
|
before(:each) do
|
6
|
-
Bumbleworks.dashboard.
|
5
|
+
allow(Bumbleworks.dashboard).to receive_messages(:get_trackers => fake_trackers)
|
7
6
|
end
|
8
7
|
|
9
8
|
describe '.all' do
|
10
9
|
it 'returns instances for each tracker in system' do
|
11
10
|
trackers = described_class.all
|
12
|
-
trackers.all? { |t| t.class == Bumbleworks::Tracker }.
|
13
|
-
trackers.map(&:id).
|
11
|
+
expect(trackers.all? { |t| t.class == Bumbleworks::Tracker }).to be_truthy
|
12
|
+
expect(trackers.map(&:id)).to match_array([
|
14
13
|
'on_error',
|
15
14
|
'global_tracker',
|
16
15
|
'local_tracker',
|
17
16
|
'local_error_intercept',
|
18
17
|
'participant_tracker'
|
19
|
-
]
|
18
|
+
])
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -29,127 +28,127 @@ describe Bumbleworks::Tracker do
|
|
29
28
|
describe '.new' do
|
30
29
|
it 'sets tracker id and fetches original_hash from dashboard' do
|
31
30
|
tr = described_class.new('global_tracker')
|
32
|
-
tr.id.
|
33
|
-
tr.original_hash.
|
31
|
+
expect(tr.id).to eq('global_tracker')
|
32
|
+
expect(tr.original_hash).to eq(fake_trackers['global_tracker'])
|
34
33
|
end
|
35
34
|
|
36
35
|
it 'sets tracker id and original_hash if directly provided' do
|
37
36
|
tr = described_class.new('global_tracker', 'snarfles')
|
38
|
-
tr.id.
|
39
|
-
tr.original_hash.
|
37
|
+
expect(tr.id).to eq('global_tracker')
|
38
|
+
expect(tr.original_hash).to eq('snarfles')
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
42
|
describe '#wfid' do
|
44
43
|
it 'returns wfid from original hash' do
|
45
|
-
described_class.new('local_tracker').wfid.
|
44
|
+
expect(described_class.new('local_tracker').wfid).to eq('my_wfid')
|
46
45
|
end
|
47
46
|
|
48
47
|
it 'returns wfid from flow expression for global trackers' do
|
49
|
-
described_class.new('global_tracker').wfid.
|
48
|
+
expect(described_class.new('global_tracker').wfid).to eq('my_wfid')
|
50
49
|
end
|
51
50
|
|
52
51
|
it 'returns nil if no wfid' do
|
53
|
-
described_class.new('on_error').wfid.
|
52
|
+
expect(described_class.new('on_error').wfid).to be_nil
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
57
56
|
describe '#process' do
|
58
57
|
it 'returns process for wfid stored in msg' do
|
59
58
|
tr = described_class.new('global_tracker')
|
60
|
-
tr.process.
|
59
|
+
expect(tr.process).to eq(Bumbleworks::Process.new('my_wfid'))
|
61
60
|
end
|
62
61
|
|
63
62
|
it 'returns nil if no wfid' do
|
64
63
|
tr = described_class.new('on_error')
|
65
|
-
tr.process.
|
64
|
+
expect(tr.process).to be_nil
|
66
65
|
end
|
67
66
|
end
|
68
67
|
|
69
68
|
describe '#global?' do
|
70
69
|
it 'returns true if not listening to events on a specific wfid' do
|
71
|
-
described_class.new('on_error').global
|
72
|
-
described_class.new('global_tracker').global
|
70
|
+
expect(described_class.new('on_error').global?).to be_truthy
|
71
|
+
expect(described_class.new('global_tracker').global?).to be_truthy
|
73
72
|
end
|
74
73
|
|
75
74
|
it 'returns false if listening to events on a specific wfid' do
|
76
|
-
described_class.new('local_tracker').global
|
75
|
+
expect(described_class.new('local_tracker').global?).to be_falsy
|
77
76
|
end
|
78
77
|
end
|
79
78
|
|
80
79
|
describe '#conditions' do
|
81
80
|
it 'returns conditions that this tracker is watching' do
|
82
|
-
described_class.new('global_tracker').conditions.
|
83
|
-
described_class.new('local_tracker').conditions.
|
84
|
-
described_class.new('local_error_intercept').conditions.
|
85
|
-
described_class.new('participant_tracker').conditions.
|
81
|
+
expect(described_class.new('global_tracker').conditions).to eq({ "tag" => [ "the_event" ] })
|
82
|
+
expect(described_class.new('local_tracker').conditions).to eq({ "tag" => [ "local_event" ] })
|
83
|
+
expect(described_class.new('local_error_intercept').conditions).to eq({ "message" => [ "/bad/" ] })
|
84
|
+
expect(described_class.new('participant_tracker').conditions).to eq({ "participant_name" => [ "goose","bunnies" ] })
|
86
85
|
end
|
87
86
|
|
88
87
|
it 'returns empty hash when no conditions' do
|
89
|
-
described_class.new('on_error').conditions.
|
88
|
+
expect(described_class.new('on_error').conditions).to eq({})
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
92
|
describe '#tags' do
|
94
93
|
it 'returns array of tags' do
|
95
|
-
described_class.new('global_tracker').tags.
|
96
|
-
described_class.new('local_tracker').tags.
|
94
|
+
expect(described_class.new('global_tracker').tags).to eq([ "the_event" ])
|
95
|
+
expect(described_class.new('local_tracker').tags).to eq([ "local_event" ])
|
97
96
|
end
|
98
97
|
|
99
98
|
it 'returns empty array if no tags' do
|
100
|
-
described_class.new('local_error_intercept').tags.
|
101
|
-
described_class.new('participant_tracker').tags.
|
99
|
+
expect(described_class.new('local_error_intercept').tags).to eq([])
|
100
|
+
expect(described_class.new('participant_tracker').tags).to eq([])
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
105
104
|
describe '#action' do
|
106
105
|
it 'returns action being awaited' do
|
107
|
-
described_class.new('global_tracker').action.
|
108
|
-
described_class.new('local_error_intercept').action.
|
109
|
-
described_class.new('participant_tracker').action.
|
106
|
+
expect(described_class.new('global_tracker').action).to eq('left_tag')
|
107
|
+
expect(described_class.new('local_error_intercept').action).to eq('error_intercepted')
|
108
|
+
expect(described_class.new('participant_tracker').action).to eq('dispatch')
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
describe '#waiting_expression' do
|
112
|
+
describe '#waiting_expression' do
|
114
113
|
it 'returns nil when no expression is waiting' do
|
115
|
-
described_class.new('on_error').waiting_expression.
|
114
|
+
expect(described_class.new('on_error').waiting_expression).to be_nil
|
116
115
|
end
|
117
116
|
|
118
|
-
it 'returns expression awaiting reply' do
|
117
|
+
it 'returns expression awaiting reply' do
|
119
118
|
process = Bumbleworks::Process.new('my_wfid')
|
120
119
|
expression1 = double(:expid => '0_0_0', :tree => :a_global_expression)
|
121
120
|
expression2 = double(:expid => '0_0_1', :tree => :a_local_expression)
|
122
|
-
process.
|
121
|
+
allow(process).to receive_messages(:expressions => [expression1, expression2])
|
123
122
|
|
124
123
|
tracker1 = described_class.new('global_tracker')
|
125
|
-
tracker1.
|
126
|
-
tracker1.waiting_expression.
|
124
|
+
allow(tracker1).to receive_messages(:process => process)
|
125
|
+
expect(tracker1.waiting_expression).to eq(:a_global_expression)
|
127
126
|
|
128
127
|
tracker2 = described_class.new('local_tracker')
|
129
|
-
tracker2.
|
130
|
-
tracker2.waiting_expression.
|
128
|
+
allow(tracker2).to receive_messages(:process => process)
|
129
|
+
expect(tracker2.waiting_expression).to eq(:a_local_expression)
|
131
130
|
end
|
132
131
|
end
|
133
132
|
|
134
133
|
describe '#where_clause' do
|
135
134
|
it 'returns where clause from waiting expression' do
|
136
135
|
tracker = described_class.new('global_tracker')
|
137
|
-
tracker.
|
136
|
+
allow(tracker).to receive_messages(:waiting_expression => [
|
138
137
|
'wait_for_event', { "where" => "some_stuff_matches" }, []
|
139
138
|
])
|
140
|
-
tracker.where_clause.
|
139
|
+
expect(tracker.where_clause).to eq('some_stuff_matches')
|
141
140
|
end
|
142
141
|
|
143
142
|
it 'returns nil when waiting_expression does not include where clause' do
|
144
143
|
tracker = described_class.new('global_tracker')
|
145
|
-
tracker.
|
144
|
+
allow(tracker).to receive_messages(:waiting_expression => [
|
146
145
|
'wait_for_event', {}, []
|
147
146
|
])
|
148
|
-
tracker.where_clause.
|
147
|
+
expect(tracker.where_clause).to be_nil
|
149
148
|
end
|
150
149
|
|
151
150
|
it 'returns nil when no waiting_expression' do
|
152
|
-
described_class.new('on_error').where_clause.
|
151
|
+
expect(described_class.new('on_error').where_clause).to be_nil
|
153
152
|
end
|
154
153
|
end
|
155
154
|
end
|
@@ -24,19 +24,20 @@ describe Bumbleworks::TreeBuilder do
|
|
24
24
|
end
|
25
25
|
)
|
26
26
|
builder = described_class.new(:name => 'luigi', :definition => pdef)
|
27
|
-
builder.build
|
27
|
+
expect(builder.build!).to eq([
|
28
28
|
"define", {"name" => "luigi"},
|
29
29
|
[
|
30
30
|
["order_pants_around", {}, []]
|
31
31
|
]
|
32
|
-
]
|
32
|
+
])
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'uses tree if given' do
|
36
36
|
tree = ["define", {"guppies" => nil}, [["swim", {}, []]]]
|
37
37
|
builder = described_class.new(:tree => tree)
|
38
|
-
builder.build
|
38
|
+
expect(builder.build!).to eq(
|
39
39
|
["define", {"name" => "guppies"}, [["swim", {}, []]]]
|
40
|
+
)
|
40
41
|
end
|
41
42
|
|
42
43
|
it 'normalizes and sets name from tree' do
|
@@ -46,12 +47,12 @@ describe Bumbleworks::TreeBuilder do
|
|
46
47
|
end
|
47
48
|
)
|
48
49
|
builder = described_class.new(:definition => pdef)
|
49
|
-
builder.build
|
50
|
+
expect(builder.build!).to eq([
|
50
51
|
"define", {"name" => "country_time_county_dime"},
|
51
52
|
[
|
52
53
|
["do_the_fig_newton", {}, []]
|
53
54
|
]
|
54
|
-
]
|
55
|
+
])
|
55
56
|
end
|
56
57
|
|
57
58
|
it 'raises error if name conflicts with name in definition' do
|
@@ -82,14 +83,15 @@ describe Bumbleworks::TreeBuilder do
|
|
82
83
|
construct :solution => 'to world conflict'
|
83
84
|
end
|
84
85
|
builder.build!
|
85
|
-
builder.tree.
|
86
|
+
expect(builder.tree).to eq(
|
86
87
|
["define", { "name" => "just_another_poodle_day" },
|
87
88
|
[
|
88
89
|
["chew", {"on" => "dad"}, []],
|
89
90
|
["construct", {"solution" => "to world conflict"}, []]
|
90
91
|
]
|
91
92
|
]
|
92
|
-
|
93
|
+
)
|
94
|
+
expect(builder.name).to eq('just_another_poodle_day')
|
93
95
|
end
|
94
96
|
end
|
95
97
|
end
|
@@ -4,23 +4,23 @@ describe Bumbleworks::User do
|
|
4
4
|
|
5
5
|
describe '#claim_token' do
|
6
6
|
it 'returns username by default' do
|
7
|
-
subject.
|
8
|
-
subject.claim_token.
|
7
|
+
allow(subject).to receive_messages(:username => 'nerfobot')
|
8
|
+
expect(subject.claim_token).to eq('nerfobot')
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns email if no username' do
|
12
|
-
subject.
|
13
|
-
subject.claim_token.
|
12
|
+
allow(subject).to receive_messages(:email => 'fromp@nougatcountry.com')
|
13
|
+
expect(subject.claim_token).to eq('fromp@nougatcountry.com')
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'prefers username to email when both respond' do
|
17
|
-
subject.
|
18
|
-
subject.claim_token.
|
17
|
+
allow(subject).to receive_messages(:username => 'dumb', :email => 'moar dumb')
|
18
|
+
expect(subject.claim_token).to eq('dumb')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'returns nil if method defined' do
|
22
|
-
subject.
|
23
|
-
subject.claim_token.
|
22
|
+
allow(subject).to receive(:username)
|
23
|
+
expect(subject.claim_token).to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'raises exception if neither username nor email defined' do
|
@@ -32,19 +32,19 @@ describe Bumbleworks::User do
|
|
32
32
|
|
33
33
|
describe '#claim' do
|
34
34
|
before(:each) do
|
35
|
-
subject.
|
36
|
-
subject.
|
35
|
+
allow(subject).to receive_messages(:role_identifiers => ['snoogat'])
|
36
|
+
allow(subject).to receive_messages(:claim_token => "the umpire of snorts")
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'claims a task if authorized' do
|
40
40
|
task = double('task', :role => 'snoogat')
|
41
|
-
task.
|
41
|
+
expect(task).to receive(:claim).with("the umpire of snorts")
|
42
42
|
subject.claim(task)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'raises exception if unauthorized' do
|
46
46
|
task = double('task', :role => 'fashbone')
|
47
|
-
task.
|
47
|
+
expect(task).to receive(:claim).never
|
48
48
|
expect {
|
49
49
|
subject.claim(task)
|
50
50
|
}.to raise_error(Bumbleworks::User::UnauthorizedClaimAttempt)
|
@@ -52,7 +52,7 @@ describe Bumbleworks::User do
|
|
52
52
|
|
53
53
|
it 'raises exception if already claimed by another' do
|
54
54
|
task = double('task', :role => 'snoogat')
|
55
|
-
task.
|
55
|
+
expect(task).to receive(:claim).and_raise(Bumbleworks::Task::AlreadyClaimed)
|
56
56
|
expect {
|
57
57
|
subject.claim(task)
|
58
58
|
}.to raise_error(Bumbleworks::Task::AlreadyClaimed)
|
@@ -61,15 +61,15 @@ describe Bumbleworks::User do
|
|
61
61
|
describe '!' do
|
62
62
|
it 'resets even if claimed by another' do
|
63
63
|
task = double('task', :role => 'snoogat', :claimed? => true, :claimant => 'fumbo the monfey')
|
64
|
-
task.
|
65
|
-
task.
|
64
|
+
expect(task).to receive(:release).ordered
|
65
|
+
expect(task).to receive(:claim).with("the umpire of snorts").ordered
|
66
66
|
subject.claim!(task)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'raises exception (and does not release) if unauthorized' do
|
70
70
|
task = double('task', :role => 'fashbone')
|
71
|
-
task.
|
72
|
-
task.
|
71
|
+
expect(task).to receive(:release).never
|
72
|
+
expect(task).to receive(:claim).never
|
73
73
|
expect {
|
74
74
|
subject.claim!(task)
|
75
75
|
}.to raise_error(Bumbleworks::User::UnauthorizedClaimAttempt)
|
@@ -79,24 +79,24 @@ describe Bumbleworks::User do
|
|
79
79
|
|
80
80
|
describe '#release' do
|
81
81
|
before(:each) do
|
82
|
-
subject.
|
82
|
+
allow(subject).to receive_messages(:claim_token => "the umpire of snorts")
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'releases a claimed task if claimant' do
|
86
86
|
task = double('task', :claimed? => true, :claimant => "the umpire of snorts")
|
87
|
-
task.
|
87
|
+
expect(task).to receive(:release)
|
88
88
|
subject.release(task)
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'does nothing if task not claimed' do
|
92
92
|
task = double('task', :claimed? => false)
|
93
|
-
task.
|
93
|
+
expect(task).to receive(:release).never
|
94
94
|
subject.release(task)
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'raises exception if not claimant' do
|
98
98
|
task = double('task', :claimed? => true, :claimant => 'a castanet expert')
|
99
|
-
task.
|
99
|
+
expect(task).to receive(:release).never
|
100
100
|
expect {
|
101
101
|
subject.release(task)
|
102
102
|
}.to raise_error(Bumbleworks::User::UnauthorizedReleaseAttempt)
|
@@ -105,7 +105,7 @@ describe Bumbleworks::User do
|
|
105
105
|
describe '!' do
|
106
106
|
it 'releases even if not claimant' do
|
107
107
|
task = double('task', :claimed? => true, :claimant => 'a castanet expert')
|
108
|
-
task.
|
108
|
+
expect(task).to receive(:release)
|
109
109
|
subject.release!(task)
|
110
110
|
end
|
111
111
|
end
|
@@ -121,41 +121,41 @@ describe Bumbleworks::User do
|
|
121
121
|
|
122
122
|
describe '#has_role?' do
|
123
123
|
before(:each) do
|
124
|
-
subject.
|
124
|
+
allow(subject).to receive_messages(:role_identifiers => ['role1', 'role2'])
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'returns true if role_identifiers includes given role' do
|
128
|
-
subject.has_role?('role1').
|
128
|
+
expect(subject.has_role?('role1')).to be_truthy
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'returns false if role_identifiers does not include given role' do
|
132
|
-
subject.has_role?('role3').
|
132
|
+
expect(subject.has_role?('role3')).to be_falsy
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe '#authorized_tasks' do
|
137
137
|
it 'returns task query for all tasks for user roles' do
|
138
|
-
subject.
|
139
|
-
Bumbleworks::Task.
|
140
|
-
subject.authorized_tasks.
|
138
|
+
allow(subject).to receive_messages(:role_identifiers => ['goose', 'midget'])
|
139
|
+
allow(Bumbleworks::Task).to receive(:for_roles).with(['goose', 'midget']).and_return(:all_the_tasks)
|
140
|
+
expect(subject.authorized_tasks).to eq(:all_the_tasks)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
144
|
describe '#claimed_tasks' do
|
145
145
|
it 'returns task query for all user claimed tasks' do
|
146
|
-
subject.
|
147
|
-
Bumbleworks::Task.
|
148
|
-
subject.claimed_tasks.
|
146
|
+
allow(subject).to receive_messages(:claim_token => :yay_its_me)
|
147
|
+
allow(Bumbleworks::Task).to receive(:for_claimant).with(:yay_its_me).and_return(:my_tasks)
|
148
|
+
expect(subject.claimed_tasks).to eq(:my_tasks)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
152
|
describe '#available_tasks' do
|
153
153
|
it 'returns authorized tasks filtered by available' do
|
154
|
-
subject.
|
154
|
+
allow(subject).to receive_messages(:role_identifiers => ['goose', 'midget'])
|
155
155
|
task_finder = double('task_finder')
|
156
|
-
task_finder.
|
157
|
-
Bumbleworks::Task.
|
158
|
-
subject.available_tasks.
|
156
|
+
allow(task_finder).to receive_messages(:available => :only_the_available_tasks)
|
157
|
+
allow(Bumbleworks::Task).to receive(:for_roles).with(['goose', 'midget']).and_return(task_finder)
|
158
|
+
expect(subject.available_tasks).to eq(:only_the_available_tasks)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -13,15 +13,15 @@ describe Bumbleworks::WorkitemEntityStorage do
|
|
13
13
|
|
14
14
|
describe '#entity_storage_workitem' do
|
15
15
|
it 'returns new Bumbleworks::Workitem instance with workitem' do
|
16
|
-
Bumbleworks::Workitem.
|
16
|
+
allow(Bumbleworks::Workitem).to receive(:new).with(:a_workitem).and_return(:the_workitem)
|
17
17
|
feh = fake_entity_holder.new(:a_workitem)
|
18
|
-
feh.entity_storage_workitem.
|
18
|
+
expect(feh.entity_storage_workitem).to eq(:the_workitem)
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'is memoized' do
|
22
22
|
feh = fake_entity_holder.new(:a_workitem)
|
23
23
|
esw = feh.entity_storage_workitem
|
24
|
-
feh.entity_storage_workitem.
|
24
|
+
expect(feh.entity_storage_workitem).to be esw
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,8 +29,8 @@ describe Bumbleworks::WorkitemEntityStorage do
|
|
29
29
|
describe "##{method}" do
|
30
30
|
it 'delegates to entity storage workitem' do
|
31
31
|
feh = fake_entity_holder.new(:a_workitem)
|
32
|
-
feh.entity_storage_workitem.
|
33
|
-
feh.send(method, 1, 2, 3).
|
32
|
+
allow(feh.entity_storage_workitem).to receive(method).with(1, 2, 3).and_return(:yay_for_bikes)
|
33
|
+
expect(feh.send(method, 1, 2, 3)).to eq(:yay_for_bikes)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|