|
103 | 103 | describe '#switch_to_the_window' do
|
104 | 104 | let(:operation) { :switch_to_the_window }
|
105 | 105 | let(:args) { { window_name: 'new' } }
|
106 |
| - let(:args_with_timeout) { { window_name: 'new', timeout: 5 } } |
| 106 | + let(:timeout_sec) { 2 } |
| 107 | + let(:args_with_timeout) { { window_name: 'new', timeout: timeout_sec } } |
107 | 108 | it 'call driver.swich_to_window_by_name' do
|
108 | 109 | expect(driver_double).to receive_message_chain(:switch_to, :window)
|
109 | 110 | subject.send(operation, args)
|
|
113 | 114 | subject.send(operation, args)
|
114 | 115 | end
|
115 | 116 | it 'call wait_until_helper with timeout argument' do
|
116 |
| - expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) } |
| 117 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
117 | 118 | subject.send(operation, args_with_timeout)
|
118 | 119 | end
|
119 | 120 | end
|
|
151 | 152 | describe '#input' do
|
152 | 153 | let(:operation) { :input }
|
153 | 154 | let(:args) { { page: 'top', part: 'form', word: 'hogehoge' } }
|
154 |
| - let(:args_with_timeout) { { page: 'top', part: 'form', word: 'hogehoge', timeout: 5 } } |
| 155 | + let(:timeout_sec) { 2 } |
| 156 | + let(:args_with_timeout) { args.merge(timeout: timeout_sec) } |
155 | 157 | let(:elem_double) { double('elem double') }
|
156 | 158 | it 'call part#send_keys' do
|
157 | 159 | expect(pages_double).to receive_message_chain(:get_part, :send_keys)
|
|
165 | 167 | it 'call wait_until_helper with timeout argument' do
|
166 | 168 | allow(pages_double).to receive_message_chain(:get_part, :send_keys).and_return(elem_double)
|
167 | 169 | # Verify that some of the arguments match.
|
168 |
| - expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) } |
| 170 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
169 | 171 | subject.send(operation, args_with_timeout)
|
170 | 172 | end
|
171 | 173 | end
|
|
182 | 184 | describe '#click' do
|
183 | 185 | let(:operation) { :click }
|
184 | 186 | let(:args) { { page: 'top', part: 'form' } }
|
185 |
| - let(:args_with_timeout) { { page: 'top', part: 'form', timeout: 5 } } |
| 187 | + let(:timeout_sec) { 2 } |
| 188 | + let(:args_with_timeout) { args.merge(timeout: timeout_sec) } |
186 | 189 | let(:elem_double) { double('elem double') }
|
187 | 190 | it 'call part#click' do
|
188 | 191 | allow(pages_double).to receive(:get_part).and_return(elem_double)
|
|
205 | 208 | allow(pages_double).to receive(:get_part).and_return(elem_double)
|
206 | 209 | allow(elem_double).to receive(:click)
|
207 | 210 | # Verify that some of the arguments match.
|
208 |
| - expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) } |
| 211 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
209 | 212 | subject.send(operation, args_with_timeout)
|
210 | 213 | end
|
211 | 214 | end
|
|
216 | 219 | let(:args_value) { { page: 'top', part: 'form', value: 1 } }
|
217 | 220 | let(:args_index) { { page: 'top', part: 'form', index: 1 } }
|
218 | 221 | let(:args_error) { { page: 'top', part: 'form', error: 1 } }
|
219 |
| - let(:args_text_with_timeout) { { page: 'top', part: 'form', text: 'foo', timeout: 5 } } |
| 222 | + let(:timeout_sec) { 2 } |
| 223 | + let(:args_text_with_timeout) { args_text.merge(timeout: timeout_sec) } |
220 | 224 | let(:option_double) { double('option double') }
|
221 | 225 | let(:elem_double) { double('elem double') }
|
222 | 226 | before do
|
|
246 | 250 | it 'call wait_until_helper with timeout argument' do
|
247 | 251 | allow(option_double).to receive(:select_by).with(:text, 'foo')
|
248 | 252 | # Verify that some of the arguments match.
|
249 |
| - expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }.and_return(option_double) |
| 253 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }.and_return(option_double) |
250 | 254 | subject.send(operation, args_text_with_timeout)
|
251 | 255 | end
|
252 | 256 | end
|
253 | 257 |
|
254 | 258 | describe '#accept_alert' do
|
255 | 259 | let(:operation) { :accept_alert }
|
256 | 260 | let(:alert_double) { double('alert double') }
|
| 261 | + let(:timeout_sec) { 2 } |
| 262 | + let(:args_timeout) { { timeout: timeout_sec } } |
257 | 263 | it 'call driver.switch_to.alert.accept' do
|
258 | 264 | expect(driver_double).to receive_message_chain(:switch_to, :alert, :accept)
|
259 | 265 | subject.send(operation, nil)
|
|
268 | 274 | allow(driver_double).to receive_message_chain(:switch_to, :alert).and_return(alert_double)
|
269 | 275 | allow(alert_double).to receive(:accept)
|
270 | 276 | # Verify that some of the arguments match.
|
271 |
| - expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(5) }.and_return(alert_double) |
272 |
| - subject.send(operation, nil) |
| 277 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(2) }.and_return(alert_double) |
| 278 | + subject.send(operation, args_timeout) |
273 | 279 | end
|
274 | 280 | end
|
275 | 281 |
|
|
0 commit comments