spec/watirspec/window_switching_spec.rb in watir-6.19.1 vs spec/watirspec/window_switching_spec.rb in watir-7.0.0.beta1

- old
+ new

@@ -41,16 +41,10 @@ it 'finds window by :title' do expect(browser.window(title: 'closeable window').use).to be_a(Watir::Window) end - it 'finds window by :index' do - expect { - expect(browser.window(index: 1).use).to be_a(Watir::Window) - }.to have_deprecated_window_index - end - it 'finds window by :element' do expect(browser.window(element: browser.a(id: 'close')).use).to be_a(Watir::Window) end it 'finds window by multiple values' do @@ -89,16 +83,10 @@ it 'raises a NoMatchingWindowFoundException error if no window matches the selector' do expect { browser.window(title: 'noop').use }.to raise_no_matching_window_exception end - it "raises a NoMatchingWindowFoundException error if there's no window at the given index" do - expect { - expect { browser.window(index: 100).use }.to raise_no_matching_window_exception - }.to have_deprecated_window_index - end - it 'raises NoMatchingWindowFoundException error when attempting to use a window with an incorrect handle' do expect { browser.window(handle: 'bar').use }.to raise_no_matching_window_exception end end @@ -254,16 +242,10 @@ it 'finds window by :title' do expect(browser.window(title: 'closeable window').handle).to_not be_nil end - it 'finds window by :index' do - expect { - expect(browser.window(index: 1).handle).to_not be_nil - }.to have_deprecated_window_index - end - it 'finds window by :element' do expect(browser.window(element: browser.a(id: 'close')).handle).to_not be_nil end it 'finds window by multiple values' do @@ -388,16 +370,10 @@ browser.original_window.use browser.windows.reject(&:current?).each(&:close) end describe '#present?' do - it 'should find window by index' do - expect { - expect(browser.window(index: 0)).to be_present - }.to have_deprecated_window_index - end - it 'should find window by url' do expect(browser.window(url: /window_switching\.html/)).to be_present end it 'should find window by title' do @@ -409,15 +385,10 @@ end end describe '#use' do context 'switching windows without blocks' do - it 'by index' do - expect { browser.window(index: 0).use }.to have_deprecated_window_index - expect(browser.title).to be == 'window switching' - end - it 'by url' do browser.window(url: /window_switching\.html/).use expect(browser.title).to be == 'window switching' end @@ -431,16 +402,10 @@ expect(browser.url).to match(/window_switching\.html/) end end context 'Switching windows with blocks' do - it 'by index' do - expect { - browser.window(index: 0).use { expect(browser.title).to be == 'window switching' } - }.to have_deprecated_window_index - end - it 'by url' do browser.window(url: /window_switching\.html/).use { expect(browser.title).to be == 'window switching' } end it 'by title' do @@ -534,14 +499,14 @@ after do browser.original_window.use browser.windows.reject(&:current?).each(&:close) end - it '#to_a' do + it '#to_a raises exception' do expect { Watir::WindowCollection.new(browser).to_a - }.to have_deprecated_window_index + }.to raise_exception(NoMethodError, 'indexing not reliable on WindowCollection') end describe '#new' do it 'returns all windows by default' do windows = Watir::WindowCollection.new(browser) @@ -578,26 +543,14 @@ it 'counts the number of matching windows' do expect(Watir::WindowCollection.new(browser).size).to eq 2 end end - describe '#[]' do - it 'returns window instance at provided index' do - windows = Watir::WindowCollection.new(browser) - - expect { - expect(windows).to all(be_an(Watir::Window)) - expect(windows.first).to_not eq windows.last - }.to have_deprecated_window_index - end - end - describe '#eq?' do it 'compares the equivalence of window handles' do windows1 = Watir::WindowCollection.new(browser, title: //) windows2 = Watir::WindowCollection.new(browser, url: //) expect(windows1).to eq windows2 - expect(windows1.to_a.map(&:handle)).to eq windows2.to_a.map(&:handle) end end end