|
109 | 109 | context 'without weight' do |
110 | 110 | let(:enum) { 1.upto(100000) } |
111 | 111 |
|
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 |
115 | 119 | specify do |
116 | 120 | result = enum.sample |
117 | 121 | expect(result).to be_an(Integer) |
118 | 122 | other_results = Array.new(100) { enum.sample } |
119 | 123 | expect(other_results).not_to be_all {|i| i == result } |
120 | 124 | end |
121 | 125 | end |
122 | | - end |
123 | 126 |
|
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 |
132 | 136 | end |
133 | | - end |
134 | 137 |
|
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 |
138 | 140 | specify do |
139 | 141 | result = enum.sample(1) |
140 | 142 | expect(result).to be_an(Integer) |
141 | 143 | other_results = Array.new(100) { enum.sample(1) } |
142 | 144 | expect(other_results).not_to be_all {|i| i == result } |
143 | 145 | end |
144 | 146 | end |
145 | | - end |
146 | 147 |
|
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 |
154 | 156 | end |
155 | 157 | end |
156 | | - end |
157 | 158 |
|
158 | | - context 'with size (> 1)' do |
159 | | - context 'without replacement' do |
| 159 | + context 'with size (> 1)' do |
160 | 160 | context 'without rng' do |
161 | 161 | subject(:result) { enum.sample(n) } |
162 | 162 |
|
|
184 | 184 | end |
185 | 185 | end |
186 | 186 | end |
| 187 | + end |
187 | 188 |
|
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 |
191 | 195 | end |
192 | 196 | end |
193 | 197 |
|
|
0 commit comments