-
Notifications
You must be signed in to change notification settings - Fork 89
/
branching_workflow_spec.rb
46 lines (36 loc) · 1.07 KB
/
branching_workflow_spec.rb
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
require 'workflows/branching_workflow'
describe BranchingWorkflow do
subject { described_class }
before do
allow_any_instance_of(RandomNumberActivity)
.to receive(:rand)
.with(0..100)
.and_return(random_number)
end
context 'when random number is below 50' do
let(:random_number) { 42 }
it 'executes HelloWorldActivity' do
expect_any_instance_of(HelloWorldActivity)
.to receive(:execute)
.with('bottom half')
.and_call_original
subject.execute_locally
end
it 'returns a picked number' do
expect(subject.execute_locally).to eq("Number picked was: #{random_number}")
end
end
context 'when random number is above 50' do
let(:random_number) { 84 }
it 'executes HelloWorldActivity' do
expect_any_instance_of(HelloWorldActivity)
.to receive(:execute)
.with('top half')
.and_call_original
subject.execute_locally
end
it 'returns a picked number' do
expect(subject.execute_locally).to eq("Number picked was: #{random_number}")
end
end
end