|
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(:timeout_sec) { 2 } |
| 107 | + let(:args_with_timeout) { { window_name: 'new', timeout: timeout_sec } } |
106 | 108 | it 'call driver.swich_to_window_by_name' do
|
107 | 109 | expect(driver_double).to receive_message_chain(:switch_to, :window)
|
108 | 110 | subject.send(operation, args)
|
|
111 | 113 | expect(subject).to receive(:wait_until_helper)
|
112 | 114 | subject.send(operation, args)
|
113 | 115 | end
|
| 116 | + it 'call wait_until_helper with timeout argument' do |
| 117 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
| 118 | + subject.send(operation, args_with_timeout) |
| 119 | + end |
114 | 120 | end
|
115 | 121 |
|
116 | 122 | describe '#close' do
|
|
146 | 152 | describe '#input' do
|
147 | 153 | let(:operation) { :input }
|
148 | 154 | let(:args) { { page: 'top', part: 'form', word: 'hogehoge' } }
|
| 155 | + let(:timeout_sec) { 2 } |
| 156 | + let(:args_with_timeout) { args.merge(timeout: timeout_sec) } |
149 | 157 | let(:elem_double) { double('elem double') }
|
150 | 158 | it 'call part#send_keys' do
|
151 | 159 | expect(pages_double).to receive_message_chain(:get_part, :send_keys)
|
|
156 | 164 | expect(subject).to receive(:wait_until_helper)
|
157 | 165 | subject.send(operation, args)
|
158 | 166 | end
|
| 167 | + it 'call wait_until_helper with timeout argument' do |
| 168 | + allow(pages_double).to receive_message_chain(:get_part, :send_keys).and_return(elem_double) |
| 169 | + # Verify that some of the arguments match. |
| 170 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
| 171 | + subject.send(operation, args_with_timeout) |
| 172 | + end |
159 | 173 | end
|
160 | 174 |
|
161 | 175 | describe '#clear' do
|
|
170 | 184 | describe '#click' do
|
171 | 185 | let(:operation) { :click }
|
172 | 186 | let(:args) { { page: 'top', part: 'form' } }
|
| 187 | + let(:timeout_sec) { 2 } |
| 188 | + let(:args_with_timeout) { args.merge(timeout: timeout_sec) } |
173 | 189 | let(:elem_double) { double('elem double') }
|
174 | 190 | it 'call part#click' do
|
175 | 191 | allow(pages_double).to receive(:get_part).and_return(elem_double)
|
|
187 | 203 | expect(subject).to receive(:wait_until_helper)
|
188 | 204 | subject.send(operation, args)
|
189 | 205 | end
|
| 206 | + |
| 207 | + it 'call wait_until_helper with timeout argument' do |
| 208 | + allow(pages_double).to receive(:get_part).and_return(elem_double) |
| 209 | + allow(elem_double).to receive(:click) |
| 210 | + # Verify that some of the arguments match. |
| 211 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) } |
| 212 | + subject.send(operation, args_with_timeout) |
| 213 | + end |
190 | 214 | end
|
191 | 215 |
|
192 | 216 | describe '#choose' do
|
|
195 | 219 | let(:args_value) { { page: 'top', part: 'form', value: 1 } }
|
196 | 220 | let(:args_index) { { page: 'top', part: 'form', index: 1 } }
|
197 | 221 | let(:args_error) { { page: 'top', part: 'form', error: 1 } }
|
| 222 | + let(:timeout_sec) { 2 } |
| 223 | + let(:args_text_with_timeout) { args_text.merge(timeout: timeout_sec) } |
198 | 224 | let(:option_double) { double('option double') }
|
199 | 225 | let(:elem_double) { double('elem double') }
|
200 | 226 | before do
|
|
221 | 247 | expect(subject).to receive(:wait_until_helper).and_return(option_double)
|
222 | 248 | subject.send(operation, args_text)
|
223 | 249 | end
|
| 250 | + it 'call wait_until_helper with timeout argument' do |
| 251 | + allow(option_double).to receive(:select_by).with(:text, 'foo') |
| 252 | + # Verify that some of the arguments match. |
| 253 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(timeout_sec) }.and_return(option_double) |
| 254 | + subject.send(operation, args_text_with_timeout) |
| 255 | + end |
224 | 256 | end
|
225 | 257 |
|
226 | 258 | describe '#accept_alert' do
|
227 | 259 | let(:operation) { :accept_alert }
|
228 | 260 | let(:alert_double) { double('alert double') }
|
| 261 | + let(:timeout_sec) { 2 } |
| 262 | + let(:args_timeout) { { timeout: timeout_sec } } |
229 | 263 | it 'call driver.switch_to.alert.accept' do
|
230 | 264 | expect(driver_double).to receive_message_chain(:switch_to, :alert, :accept)
|
231 | 265 | subject.send(operation, nil)
|
|
236 | 270 | expect(subject).to receive(:wait_until_helper).and_return(alert_double)
|
237 | 271 | subject.send(operation, nil)
|
238 | 272 | end
|
| 273 | + it 'call wait_until_helper with timeout argument' do |
| 274 | + allow(driver_double).to receive_message_chain(:switch_to, :alert).and_return(alert_double) |
| 275 | + allow(alert_double).to receive(:accept) |
| 276 | + # Verify that some of the arguments match. |
| 277 | + expect(subject).to receive(:wait_until_helper) { |timeout, *| expect(timeout).to eq(2) }.and_return(alert_double) |
| 278 | + subject.send(operation, args_timeout) |
| 279 | + end |
239 | 280 | end
|
240 | 281 |
|
241 | 282 | describe '#wait' do
|
|
0 commit comments