1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
require 'qunit/selenium/test_runner'
module QUnit
module Selenium
describe TestRunner do
shared_examples 'open test page' do |timeout|
let(:test_run) {double('test_run')}
let(:wait) {double('wait')}
before do
allow(TestRun).to receive(:new).with(driver).and_return(test_run)
allow(::Selenium::WebDriver::Wait).to receive(:new).with(timeout: timeout).and_return(wait)
allow(wait).to receive(:until).and_yield
expect(test_run).to receive(:completed?).ordered
allow(test_run).to receive(:result).and_return('result')
end
it 'returns the completed test run' do
expect(subject).to eq('result')
end
end
let(:driver) {double('driver')}
before do
expect(driver).to receive(:get).with('test_url').ordered
end
describe ' #open' do
context 'default options' do
let(:subject) {TestRunner.new(driver).open('test_url')}
include_examples 'open test page', 10
end
context 'custom options' do
let(:subject) {TestRunner.new(driver).open('test_url', timeout: 30)}
include_examples 'open test page', 30
end
end
end
end
end
|