Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Remove deprecated functionality #801

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ env:
global:
- BUNDLE_JOBS=4
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
matrix:
include:
- rvm: 1.9.3
gemfile: gemfiles/2.3.gemfile
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
- rvm: 1.9.3
gemfile: gemfiles/2.4.gemfile
env: QMAKE=/usr/lib/x86_64-linux-gnu/qt5/bin/qmake
gemfile:
- gemfiles/2.3.gemfile
- gemfiles/2.4.gemfile
before_install:
- sh -c 'if [ -n "$QMAKE" ]; then sudo apt-add-repository -y ppa:ubuntu-sdk-team/ppa && sudo apt-get update && sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev; fi'
- sudo apt-add-repository -y ppa:ubuntu-sdk-team/ppa
- sudo apt-get update
- sudo apt-get install libqt5webkit5-dev qtdeclarative5-dev qt5-default
install: bundle
54 changes: 0 additions & 54 deletions lib/capybara/webkit/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,6 @@ def error_messages
end
end

def alert_messages
JSON.parse(command("JavascriptAlertMessages"))
end

def confirm_messages
JSON.parse(command("JavascriptConfirmMessages"))
end

def prompt_messages
JSON.parse(command("JavascriptPromptMessages"))
end

def response_headers
JSON.parse(command("Headers"))
end
Expand Down Expand Up @@ -127,38 +115,18 @@ def get_window_handles
JSON.parse(command('GetWindowHandles'))
end

def window_handles
warn '[DEPRECATION] Capybara::Webkit::Browser#window_handles ' \
'is deprecated. Please use Capybara::Session#windows instead.'
get_window_handles
end

def get_window_handle
command('GetWindowHandle')
end

def window_handle
warn '[DEPRECATION] Capybara::Webkit::Browser#window_handle ' \
'is deprecated. Please use Capybara::Session#current_window instead.'
get_window_handle
end

def accept_confirm(options)
command("SetConfirmAction", "Yes", options[:text])
end

def accept_js_confirms
command("SetConfirmAction", "Yes")
end

def reject_confirm(options)
command("SetConfirmAction", "No", options[:text])
end

def reject_js_confirms
command("SetConfirmAction", "No")
end

def accept_prompt(options)
if options[:with]
command("SetPromptAction", "Yes", options[:text], options[:with])
Expand All @@ -167,26 +135,10 @@ def accept_prompt(options)
end
end

def accept_js_prompts
command("SetPromptAction", "Yes")
end

def reject_prompt(options)
command("SetPromptAction", "No", options[:text])
end

def reject_js_prompts
command("SetPromptAction", "No")
end

def set_prompt_text_to(string)
command("SetPromptText", string)
end

def clear_prompt_text
command("ClearPromptText")
end

def accept_alert(options)
command("AcceptAlert", options[:text])
end
Expand All @@ -195,12 +147,6 @@ def find_modal(id)
command("FindModal", id)
end

def url_blacklist=(black_list)
warn '[DEPRECATION] Capybara::Webkit::Browser#url_blacklist= ' \
'is deprecated. Please use page.driver.block_url instead.'
command("SetUrlBlacklist", *Array(black_list))
end

def command(name, *args)
@connection.puts name
@connection.puts args.size
Expand Down
19 changes: 2 additions & 17 deletions lib/capybara/webkit/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,7 @@ class Connection

def initialize(options = {})
@socket = nil
if options.has_key?(:socket_class)
warn '[DEPRECATION] The Capybara::Webkit::Connection `socket_class` ' \
'option is deprecated without replacement.'
@socket_class = options[:socket_class]
else
@socket_class = TCPSocket
end
if options.has_key?(:stderr)
@output_target = options[:stderr]
elsif options.has_key?(:stdout)
warn '[DEPRECATION] The Capybara::Webkit::Connection `stdout` option ' \
'is deprecated. Please use `stderr` instead.'
@output_target = options[:stdout]
else
@output_target = $stderr
end
@output_target = options.fetch(:stderr) { $stderr }
start_server
connect
end
Expand Down Expand Up @@ -116,7 +101,7 @@ def connect
end

def attempt_connect
@socket = @socket_class.open("127.0.0.1", @port)
@socket = TCPSocket.open("127.0.0.1", @port)
if defined?(Socket::TCP_NODELAY)
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, true)
end
Expand Down
113 changes: 0 additions & 113 deletions lib/capybara/webkit/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,6 @@ def initialize(app, options={})
apply_options
end

def enable_logging
deprecate_and_replace_with_config "enable_logging", "debug = true"
@browser.enable_logging
end

def allow_url(url)
deprecate_and_replace_with_config "allow_url", "allow_url(#{url.inspect})"
@browser.allow_url(url)
end

def block_url(url)
deprecate_and_replace_with_config "block_url", "block_url(#{url.inspect})"
@browser.block_url(url)
end

def block_unknown_urls
deprecate_and_replace_with_config "block_unknown_urls"
@browser.block_unknown_urls
end

def allow_unknown_urls
deprecate_and_replace_with_config "allow_unknown_urls"
@browser.allow_url("*")
end

def current_url
@browser.current_url
end
Expand Down Expand Up @@ -91,26 +66,6 @@ def error_messages
@browser.error_messages
end

def alert_messages
warn '[DEPRECATION] Capybara::Webkit::Driver#alert_messages ' \
'is deprecated. Please use Capybara::Session#accept_alert instead.'
@browser.alert_messages
end

def confirm_messages
warn '[DEPRECATION] Capybara::Webkit::Driver#confirm_messages ' \
'is deprecated. Please use Capybara::Session#accept_confirm ' \
'or Capybara::Session#dismiss_confirm instead.'
@browser.confirm_messages
end

def prompt_messages
warn '[DEPRECATION] Capybara::Webkit::Driver#prompt_messages ' \
'is deprecated. Please use Capybara::Session#accept_prompt ' \
'or Capybara::Session#dismiss_prompt instead.'
@browser.prompt_messages
end

def response_headers
@browser.response_headers
end
Expand All @@ -119,12 +74,6 @@ def status_code
@browser.status_code
end

def resize_window(width, height)
warn '[DEPRECATION] Capybara::Webkit::Driver#resize_window ' \
'is deprecated. Please use Capybara::Window#resize_to instead.'
resize_window_to(current_window_handle, width, height)
end

def resize_window_to(handle, width, height)
@browser.window_resize(handle, width, height)
end
Expand Down Expand Up @@ -176,40 +125,6 @@ def maximize_window(selector)
@browser.window_maximize(selector)
end

def accept_js_confirms!
warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_confirms! ' \
'is deprecated. Please use Capybara::Session#accept_confirm instead.'
@browser.accept_js_confirms
end

def dismiss_js_confirms!
warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_confirms! ' \
'is deprecated. Please use Capybara::Session#dismiss_confirm instead.'
@browser.reject_js_confirms
end

def accept_js_prompts!
warn '[DEPRECATION] Capybara::Webkit::Driver#accept_js_prompts! ' \
'is deprecated. Please use Capybara::Session#accept_prompt instead.'
@browser.accept_js_prompts
end

def dismiss_js_prompts!
warn '[DEPRECATION] Capybara::Webkit::Driver#dismiss_js_prompts! ' \
'is deprecated. Please use Capybara::Session#dismiss_prompt instead.'
@browser.reject_js_prompts
end

def js_prompt_input=(value)
warn '[DEPRECATION] Capybara::Webkit::Driver#js_prompt_input= ' \
'is deprecated. Please use Capybara::Session#accept_prompt instead.'
if value.nil?
@browser.clear_prompt_text
else
@browser.set_prompt_text_to(value)
end
end

def go_back
@browser.go_back
end
Expand Down Expand Up @@ -306,24 +221,6 @@ def authenticate(username, password)
@browser.authenticate(username, password)
end

def timeout
deprecate_and_replace_with_config "timeout"
@browser.timeout
end

def timeout=(timeout)
deprecate_and_replace_with_config(
"timeout=",
"timeout = #{timeout.inspect}"
)
@browser.timeout = timeout
end

def browser
warn "[DEPRECATION] Capybara::Webkit::Driver#browser is deprecated."
@browser
end

private

def modal_action_options_for_browser(options)
Expand Down Expand Up @@ -374,15 +271,5 @@ def apply_options
Array(@options[:allowed_urls]).each { |url| @browser.allow_url(url) }
Array(@options[:blocked_urls]).each { |url| @browser.block_url(url) }
end

def deprecate_and_replace_with_config(deprecated_method, config_syntax = deprecated_method)
warn "[DEPRECATION] #{deprecated_method} is deprecated. " \
"Please use Capybara::Webkit.configure instead:\n\n" \
" Capybara::Webkit.configure do |config|\n" \
" config.#{config_syntax}\n" \
" end\n\n" \
"This option is global and can be configured once" \
" (not in a `before` or `setup` block)."
end
end
end
3 changes: 3 additions & 0 deletions lib/capybara/webkit/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ModalNotFound < StandardError
class CrashError < StandardError
end

class UnhandledModalError < StandardError
end

class JsonError
def initialize(response)
error = JSON.parse response
Expand Down
11 changes: 0 additions & 11 deletions spec/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ def eventually
Capybara::Webkit::Connection.new(:stderr => nil)
end

it 'prints a deprecation warning if the stdout option is used' do
Capybara::Webkit::Connection.any_instance.should_receive(:warn)
Capybara::Webkit::Connection.new(:stdout => nil)
end

it 'does not forward stdout to nil if the stdout option is used' do
Capybara::Webkit::Connection.any_instance.stub(:warn)
IO.should_not_receive(:copy_stream)
Capybara::Webkit::Connection.new(:stdout => nil)
end

it "returns the server port" do
connection.port.should be_between 0x400, 0xffff
end
Expand Down
2 changes: 1 addition & 1 deletion spec/driver_rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def render(options)
end

context "with a custom viewport size" do
before { driver.resize_window(800, 600) }
before { driver.resize_window_to(driver.current_window_handle, 800, 600) }

it "should restore viewport dimensions after rendering" do
render({})
Expand Down
12 changes: 6 additions & 6 deletions spec/driver_resize_window_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'capybara/webkit/driver'

describe Capybara::Webkit::Driver, "#resize_window(width, height)" do
describe Capybara::Webkit::Driver, "#resize_window_to(handle, width, height)" do
include AppRunner

let(:driver) do
Expand All @@ -26,21 +26,21 @@
it "resizes the window to the specified size" do
driver.visit("#{AppRunner.app_host}/")

driver.resize_window(800, 600)
driver.resize_window_to(driver.current_window_handle, 800, 600)
driver.html.should include("[800x600]")

driver.resize_window(300, 100)
driver.resize_window_to(driver.current_window_handle, 300, 100)
driver.html.should include("[300x100]")
end

it "resizes the window to the specified size even before the document has loaded" do
driver.resize_window(800, 600)
driver.resize_window_to(driver.current_window_handle, 800, 600)
driver.visit("#{AppRunner.app_host}/")
driver.html.should include("[800x600]")
end

it "resets the window to the default size when the driver is reset" do
driver.resize_window(800, 600)
driver.resize_window_to(driver.current_window_handle, 800, 600)
driver.reset!
driver.visit("#{AppRunner.app_host}/")
driver.html.should include(DEFAULT_DIMENTIONS)
Expand All @@ -60,7 +60,7 @@

it "maximizes a window" do
driver.visit("#{AppRunner.app_host}/")
driver.resize_window(400, 300)
driver.resize_window_to(driver.current_window_handle, 400, 300)
driver.maximize_window(driver.current_window_handle)
width, height = *driver.window_size(driver.current_window_handle)

Expand Down
Loading