Skip to content

Commit

Permalink
fix some order dependent tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed May 10, 2018
1 parent d2a35ff commit 3db0ca1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -1,3 +1,4 @@
--color
--require fuubar
--format Fuubar
--order random
25 changes: 20 additions & 5 deletions lib/capybara/spec/session/window/window_spec.rb
Expand Up @@ -109,9 +109,17 @@ def win_size
end

describe '#resize_to' do
before do
@initial_size = @session.current_window.size
end
after do
@session.current_window.resize_to(*@initial_size)
sleep 0.5
end

it 'should be able to resize window', requires: %i[windows js] do
width, height = @session.current_window.size
@session.current_window.resize_to(width - 100, height - 100)
width, height = @initial_size
@session.current_window.resize_to(width -100, height - 100)
sleep 1
expect(@session.current_window.size).to eq([width - 100, height - 100])
end
Expand All @@ -132,6 +140,14 @@ def win_size
end

describe '#maximize' do
before do
@initial_size = @session.current_window.size
end
after do
@session.current_window.resize_to(*@initial_size)
sleep 0.5
end

it 'should be able to maximize window', requires: %i[windows js] do
start_width, start_height = 400, 300
@session.current_window.resize_to(start_width, start_height)
Expand All @@ -148,18 +164,17 @@ def win_size
end

it 'should stay on current window if invoked not for current window', requires: %i[windows js] do
cur_window_size = @session.current_window.size
@other_window = @session.window_opened_by do
@session.find(:css, '#openWindow').click
end

@other_window.resize_to(400, 300)
sleep 0.5
@other_window.maximize
sleep 0.5 # The timing on maximize is finicky on Travis -- wait a bit for maximize to occur

expect(@session.current_window).to eq(@window)
expect(@session.current_window.size).to eq(cur_window_size)
# Maximizing the browser affects all tabs so this may not be valid in real browsers
# expect(@session.current_window.size).to eq(@initial_size)

ow_width, ow_height = @other_window.size
expect(ow_width).to be > 400
Expand Down

0 comments on commit 3db0ca1

Please sign in to comment.