capybara 2.16.0 → 2.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee26f641aae1c298d4f5c3d7e8a98376c133c1e2d6ac90b3a3a274ae0dddd13f
4
- data.tar.gz: 12a92103cb8b03439ba345d2433385d5d8ec698713c1fda8d8d496c1d7a5db4a
3
+ metadata.gz: 94085614fef28d8c100eac0e0e11e213f0bb89ab487bb538a864da3b2ec21951
4
+ data.tar.gz: b61bc9c51db0e61c730bd14e3d593ff9885e45178403dd5200a368f3e67fc8e2
5
5
  SHA512:
6
- metadata.gz: b63bffec8f36f684af468659992edc8368844838a7f92f0cacaca2cfb070c8d5d62baebc6308dc60bac7646a0e4a7221eca416014cbdc2a0f82ce189dedc1172
7
- data.tar.gz: 26d2d8319225c85ef3ea5c1c546f321a92063adcf08a97ed1e530782e7af18aa9c7b2e8c59faaac2bf02c5a3d0d7d37d82a124dc1a0472605296745fe26f2ca8
6
+ metadata.gz: 465a59847ac6f986ab374e6a84c678078c8804a60341c9ecd52625cf86e1041d98629806a4e4dc08531337e9db8190dfdbea3e64e40387ad3f16bb5a1d42cf09
7
+ data.tar.gz: 43a4b4aaead1b7a66058269e5f8ea3f09782a2c7766c0bb7cd4c3e7f56abe7b852fe28859d3ef746135798e73b86c8c72dde7fdabce57f2765b58639c232b1e8
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ # Version 2.16.1
2
+ Release data: 2017-11-20
3
+
4
+ ### Fixed
5
+
6
+ * Fix rack_test driver for rack_test 0.7.1/0.8.0 [Thomas Walpole]
7
+ * `accept_prompt` response text can contain quotes when using selenium with headless chrome [Thomas Walpole]
8
+
1
9
  # Version 2.16.0
2
10
  Release date: 2017-11-13
3
11
 
@@ -13,6 +13,8 @@ class Capybara::RackTest::Form < Capybara::RackTest::Node
13
13
  def original_filename; ""; end
14
14
  def content_type; "application/octet-stream"; end
15
15
  def path; @empty_file.path; end
16
+ def size; 0; end
17
+ def read; ""; end
16
18
  end
17
19
 
18
20
  def params(button)
@@ -36,25 +36,8 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
36
36
  end
37
37
 
38
38
  def initialize(app, options={})
39
+ load_selenium
39
40
  @session = nil
40
- begin
41
- require 'selenium-webdriver'
42
- # Fix for selenium-webdriver 3.4.0 which misnamed these
43
- if !defined?(::Selenium::WebDriver::Error::ElementNotInteractableError)
44
- ::Selenium::WebDriver::Error.const_set('ElementNotInteractableError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
45
- end
46
- if !defined?(::Selenium::WebDriver::Error::ElementClickInterceptedError)
47
- ::Selenium::WebDriver::Error.const_set('ElementClickInterceptedError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
48
- end
49
- rescue LoadError => e
50
- if e.message =~ /selenium-webdriver/
51
- raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
52
- else
53
- raise e
54
- end
55
- end
56
-
57
-
58
41
  @app = app
59
42
  @browser = nil
60
43
  @exit_status = nil
@@ -375,6 +358,16 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
375
358
  end
376
359
 
377
360
  def insert_modal_handlers(accept, response_text)
361
+ prompt_response = if accept
362
+ if response_text.nil?
363
+ "default_text"
364
+ else
365
+ "'#{response_text.gsub("\\", "\\\\\\").gsub("'", "\\\\'")}'"
366
+ end
367
+ else
368
+ 'null'
369
+ end
370
+
378
371
  script = <<-JS
379
372
  if (typeof window.capybara === 'undefined') {
380
373
  window.capybara = {
@@ -412,7 +405,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
412
405
  }
413
406
  window.prompt = function(str = "", default_text = "") {
414
407
  window.capybara.handler_called(modal_handler, str.toString());
415
- return #{accept ? (response_text.nil? ? "default_text" : "'#{response_text}'") : 'null'};
408
+ return #{prompt_response};
416
409
  }
417
410
  JS
418
411
  execute_script script
@@ -497,4 +490,23 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
497
490
  arg
498
491
  end
499
492
  end
493
+
494
+ def load_selenium
495
+ begin
496
+ require 'selenium-webdriver'
497
+ # Fix for selenium-webdriver 3.4.0 which misnamed these
498
+ if !defined?(::Selenium::WebDriver::Error::ElementNotInteractableError)
499
+ ::Selenium::WebDriver::Error.const_set('ElementNotInteractableError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
500
+ end
501
+ if !defined?(::Selenium::WebDriver::Error::ElementClickInterceptedError)
502
+ ::Selenium::WebDriver::Error.const_set('ElementClickInterceptedError', Class.new(::Selenium::WebDriver::Error::WebDriverError))
503
+ end
504
+ rescue LoadError => e
505
+ if e.message =~ /selenium-webdriver/
506
+ raise LoadError, "Capybara's selenium driver is unable to load `selenium-webdriver`, please install the gem and add `gem 'selenium-webdriver'` to your Gemfile if you are using bundler."
507
+ else
508
+ raise e
509
+ end
510
+ end
511
+ end
500
512
  end
@@ -40,13 +40,20 @@ Capybara::SpecHelper.spec '#accept_prompt', requires: [:modals] do
40
40
  end
41
41
 
42
42
  it "should accept the prompt with a blank response when there is a default" do
43
- pending "Geckodriver doesn't set a blank response currently" if @session.respond_to?(:mode) && @session.mode.to_s == "selenium_marionette"
43
+ pending "Geckodriver doesn't set a blank response currently" if marionette?(@session)
44
44
  @session.accept_prompt with: '' do
45
45
  @session.click_link('Open defaulted prompt')
46
46
  end
47
47
  expect(@session).to have_xpath("//a[@id='open-prompt-with-default' and @response='']")
48
48
  end
49
49
 
50
+ it "should allow special characters in the reponse" do
51
+ @session.accept_prompt with: '\'the\' \b "response"' do
52
+ @session.click_link('Open prompt')
53
+ end
54
+ expect(@session).to have_xpath(%{//a[@id='open-prompt' and @response=concat("'the' ", '\\b "response"')]})
55
+ end
56
+
50
57
  it "should accept the prompt if the message matches" do
51
58
  @session.accept_prompt 'Prompt opened', with: 'matched' do
52
59
  @session.click_link('Open prompt')
@@ -62,7 +69,6 @@ Capybara::SpecHelper.spec '#accept_prompt', requires: [:modals] do
62
69
  end.to raise_error(Capybara::ModalNotFound)
63
70
  end
64
71
 
65
-
66
72
  it "should return the message presented" do
67
73
  message = @session.accept_prompt with: 'the response' do
68
74
  @session.click_link('Open prompt')
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Capybara
3
- VERSION = '2.16.0'
3
+ VERSION = '2.16.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.16.0
4
+ version: 2.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Walpole
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - gem-public_cert.pem
13
- date: 2017-11-13 00:00:00.000000000 Z
13
+ date: 2017-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri