Skip to content

Commit 70eadf3

Browse files
committed
Reorganize example groups
1 parent e095eea commit 70eadf3

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

spec/enum/sample_spec.rb

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -109,54 +109,54 @@
109109
context 'without weight' do
110110
let(:enum) { 1.upto(100000) }
111111

112-
context 'without size' do
113-
context 'without rng' do
114-
context 'without weight' do
112+
specify { expect(opts).not_to include(:weights) }
113+
114+
context 'without replacement' do
115+
specify { expect(opts).not_to include(:replace) }
116+
117+
context 'without size' do
118+
context 'without rng' do
115119
specify do
116120
result = enum.sample
117121
expect(result).to be_an(Integer)
118122
other_results = Array.new(100) { enum.sample }
119123
expect(other_results).not_to be_all {|i| i == result }
120124
end
121125
end
122-
end
123126

124-
context 'with rng' do
125-
specify do
126-
save_random = random.dup
127-
result = enum.sample(random: random)
128-
expect(result).to be_an(Integer)
129-
other_results = Array.new(100) { enum.sample(random: save_random.dup) }
130-
expect(other_results).to be_all {|i| i == result }
131-
end
127+
context 'with rng' do
128+
specify do
129+
save_random = random.dup
130+
result = enum.sample(random: random)
131+
expect(result).to be_an(Integer)
132+
other_results = Array.new(100) { enum.sample(random: save_random.dup) }
133+
expect(other_results).to be_all {|i| i == result }
134+
end
135+
end
132136
end
133-
end
134137

135-
context 'with size (== 1)' do
136-
context 'without rng' do
137-
context 'without weight' do
138+
context 'with size (== 1)' do
139+
context 'without rng' do
138140
specify do
139141
result = enum.sample(1)
140142
expect(result).to be_an(Integer)
141143
other_results = Array.new(100) { enum.sample(1) }
142144
expect(other_results).not_to be_all {|i| i == result }
143145
end
144146
end
145-
end
146147

147-
context 'with rng' do
148-
specify do
149-
save_random = random.dup
150-
result = enum.sample(1, random: random)
151-
expect(result).to be_an(Integer)
152-
other_results = Array.new(100) { enum.sample(1, random: save_random.dup) }
153-
expect(other_results).to be_all {|i| i == result }
148+
context 'with rng' do
149+
specify do
150+
save_random = random.dup
151+
result = enum.sample(1, random: random)
152+
expect(result).to be_an(Integer)
153+
other_results = Array.new(100) { enum.sample(1, random: save_random.dup) }
154+
expect(other_results).to be_all {|i| i == result }
155+
end
154156
end
155157
end
156-
end
157158

158-
context 'with size (> 1)' do
159-
context 'without replacement' do
159+
context 'with size (> 1)' do
160160
context 'without rng' do
161161
subject(:result) { enum.sample(n) }
162162

@@ -184,10 +184,14 @@
184184
end
185185
end
186186
end
187+
end
187188

188-
context 'with replacement' do
189-
pending
190-
end
189+
context 'with replacement' do
190+
let(:replace) { true }
191+
192+
specify { expect(opts).to include(replace: true) }
193+
194+
pending
191195
end
192196
end
193197

0 commit comments

Comments
 (0)