Skip to content

Commit 9be3236

Browse files
committed
Add specs for Set initialization behavior
1 parent d62d9eb commit 9be3236

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/concurrent/set_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@ module Concurrent
33
RSpec.describe Set do
44
let!(:set) { described_class.new }
55

6+
describe '.[]' do
7+
describe 'when initializing with no arguments' do
8+
it do
9+
expect(described_class[]).to be_empty
10+
end
11+
end
12+
13+
describe 'when initializing with arguments' do
14+
it 'creates a set with the given objects' do
15+
expect(described_class[:hello, :world]).to eq ::Set.new([:hello, :world])
16+
end
17+
end
18+
end
19+
20+
describe '.new' do
21+
describe 'when initializing with no arguments' do
22+
it do
23+
expect(described_class.new).to be_empty
24+
end
25+
end
26+
27+
describe 'when initializing with an enumerable object' do
28+
let(:enumerable_object) { [:hello, :world] }
29+
30+
it 'creates a set with the contents of the enumerable object' do
31+
expect(described_class.new(enumerable_object)).to eq ::Set.new([:hello, :world])
32+
end
33+
34+
describe 'when initializing with a block argument' do
35+
let(:block_argument) { proc { |value| :"#{value}_ruby" } }
36+
37+
it 'creates a set with the contents of the enumerable object' do
38+
expect(described_class.new(enumerable_object, &block_argument)).to eq ::Set.new([:hello_ruby, :world_ruby])
39+
end
40+
end
41+
end
42+
end
43+
644
context 'concurrency' do
745
it do
846
(1..Concurrent::ThreadSafe::Test::THREADS).map do |i|

0 commit comments

Comments
 (0)