Skip to content

Commit d8e6f5e

Browse files
committed
added probe specs
1 parent 5b71e7a commit d8e6f5e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

spec/concurrent/channel/probe_spec.rb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,47 @@
33
module Concurrent
44

55
describe Probe do
6-
it 'should be written'
6+
7+
let(:probe) { Probe.new }
8+
9+
describe '#set_unless_assigned' do
10+
context 'empty probe' do
11+
it 'assigns the value' do
12+
probe.set_unless_assigned(32)
13+
probe.value.should eq 32
14+
end
15+
16+
it 'returns true' do
17+
probe.set_unless_assigned('hi').should eq true
18+
end
19+
end
20+
21+
context 'fulfilled probe' do
22+
before(:each) { probe.set(27) }
23+
24+
it 'does not assign the value' do
25+
probe.set_unless_assigned(88)
26+
probe.value.should eq 27
27+
end
28+
29+
it 'returns false' do
30+
probe.set_unless_assigned('hello').should eq false
31+
end
32+
end
33+
34+
context 'rejected probe' do
35+
before(:each) { probe.fail }
36+
37+
it 'does not assign the value' do
38+
probe.set_unless_assigned(88)
39+
probe.should be_rejected
40+
end
41+
42+
it 'returns false' do
43+
probe.set_unless_assigned('hello').should eq false
44+
end
45+
end
46+
end
47+
748
end
849
end

0 commit comments

Comments
 (0)