Skip to content

Commit c1ab8ca

Browse files
committed
Add specs for Semaphore#release
1 parent 6dec44e commit c1ab8ca

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/concurrent/atomic/semaphore_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,28 @@
112112
expect(semaphore.available_permits).to eq 0
113113
end
114114
end
115+
116+
describe '#release' do
117+
it 'increases the number of available permits by one' do
118+
semaphore.release
119+
expect(semaphore.available_permits).to eq 4
120+
end
121+
122+
context 'when a number of permits is specified' do
123+
it 'increases the number of available permits by the specified value' do
124+
semaphore.release(2)
125+
expect(semaphore.available_permits).to eq 5
126+
end
127+
128+
context 'when permits is set to zero' do
129+
it do
130+
expect {
131+
semaphore.release(0)
132+
}.to raise_error(ArgumentError)
133+
end
134+
end
135+
end
136+
end
115137
end
116138

117139
module Concurrent

0 commit comments

Comments
 (0)