forked from coinbase/cadence-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfailing_workflow_spec.rb
More file actions
38 lines (30 loc) · 858 Bytes
/
failing_workflow_spec.rb
File metadata and controls
38 lines (30 loc) · 858 Bytes
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
require 'workflows/failing_workflow'
describe FailingWorkflow do
subject { described_class }
before do
allow_any_instance_of(RandomlyFailingActivity)
.to receive(:rand)
.with(6)
.and_return(random_number)
end
context 'when random number is 0' do
let(:random_number) { 0 }
it 'raises' do
expect do
subject.execute_locally
end.to raise_error(RandomlyFailingActivity::TerminalGuess, 'You are the unluckiest!')
end
end
context 'when random number is 2' do
let(:random_number) { 2 }
it 'returns result' do
expect(subject.execute_locally).to eq('You are very lucky!')
end
end
context 'when random number neither 0 nor 2' do
let(:random_number) { 4 }
it 'returns result' do
expect(subject.execute_locally).to eq('Better luck next time')
end
end
end