capybara 2.9.1 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc4841dedf9ca38322cb47a786b24f8628e62fd2
4
- data.tar.gz: be5ea00f82b66a46769eab36218b26be66dda267
3
+ metadata.gz: db09e9654963783c82ada646c4814ddc80c2ddb7
4
+ data.tar.gz: 17cd310533f903c6074ab255346e37c40046f3e9
5
5
  SHA512:
6
- metadata.gz: 266ef0ca4cec47b1692544d070b6cf467f366d52d4675dae21b2e2cce3985f9ea8a5b268f70d71e290cabe4f0fbf7134b39283e2ea180cabd7610d7c34ec06f7
7
- data.tar.gz: d4ec85892ef15b4f1fee2b51b8b52a51119baaaf2a09b0abb096621197608e545036c0146cbcb64d860736cf014bb375186fec6d4f13d66e04e79959e174470c
6
+ metadata.gz: e20f671c5012aa0edcc8b51e9cd75fcac85ef8e8d784131e12cba87a1d89d6464f64d77f529787803b702d628022a48bf114ad37550995c354c409e25bb2f0b8
7
+ data.tar.gz: 3257116b6f9eb2584a154aecdc82342a1486a420eff1ebccb9df680ad0816d1f7a15aa1bc5aa8b321dc09471c6c991f035c35aa1c731fa17aa2d6827135a9667
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ #Version 2.9.2
2
+ Release date: 2016-09-29
3
+
4
+ ### Fixed
5
+ * :label built-in selector finds nested label/control by control id if the label has no 'for' attribute [Thomas Walpole]
6
+ * Warning issued if an unknown selector type is specified
7
+
1
8
  #Version 2.9.1
2
9
  Release date: 2016-09-23
3
10
 
data/README.md CHANGED
@@ -13,7 +13,7 @@ through an external gem.
13
13
  **Need help?** Ask on the mailing list (please do not open an issue on
14
14
  GitHub): http://groups.google.com/group/ruby-capybara
15
15
 
16
- **Note: Firefox 48** If you're using Firefox with selenium-webdriver, stay on either Firefox [45.0esr](https://ftp.mozilla.org/pub/firefox/releases/45.0esr/) or [47.0.1](https://ftp.mozilla.org/pub/firefox/releases/47.0.1/) and selenium-webdriver 2.53.4. Firefox 48 requires geckodriver and selenium-webdriver v3, the combo of which currently has multiple issues and is feature incomplete.
16
+ **Note: Firefox 48+** If you're using Firefox with selenium-webdriver, stay on either Firefox [45.0esr](https://ftp.mozilla.org/pub/firefox/releases/45.0esr/) or [47.0.1](https://ftp.mozilla.org/pub/firefox/releases/47.0.1/) and selenium-webdriver 2.53.4. Firefox 48+ requires geckodriver and selenium-webdriver v3, the combo of which currently has multiple issues and is feature incomplete.
17
17
 
18
18
  ## Table of contents
19
19
 
@@ -11,7 +11,10 @@ module Capybara
11
11
  @options = if args.last.is_a?(Hash) then args.pop.dup else {} end
12
12
 
13
13
  if args[0].is_a?(Symbol)
14
- @selector = Selector.all[args.shift]
14
+ @selector = Selector.all.fetch(args.shift) do |selector_type|
15
+ warn "Unknown selector type (:#{selector_type}), defaulting to :#{Capybara.default_selector} - This will raise an exception in a future version of Capybara"
16
+ nil
17
+ end
15
18
  @locator = args.shift
16
19
  else
17
20
  @selector = Selector.all.values.find { |s| s.match?(args[0]) }
@@ -429,21 +429,25 @@ end
429
429
  #
430
430
  Capybara.add_selector(:label) do
431
431
  label "label"
432
- xpath do |locator|
432
+ xpath(:for) do |locator, options|
433
433
  xpath = XPath.descendant(:label)
434
434
  xpath = xpath[XPath.string.n.is(locator.to_s) | XPath.attr(:id).equals(locator.to_s)] unless locator.nil?
435
+ if options.has_key?(:for) && !options[:for].is_a?(Capybara::Node::Element)
436
+ xpath = xpath[XPath.attr(:for).equals(options[:for].to_s).or((~XPath.attr(:for)).and(XPath.descendant()[XPath.attr(:id).equals(options[:for].to_s)]))]
437
+ end
435
438
  xpath
436
439
  end
437
440
 
438
441
  filter(:for) do |node, field_or_value|
439
442
  if field_or_value.is_a? Capybara::Node::Element
440
- if field_or_value[:id] && (field_or_value[:id] == node[:for])
441
- true
443
+ if node[:for]
444
+ field_or_value[:id] == node[:for]
442
445
  else
443
446
  field_or_value.find_xpath('./ancestor::label[1]').include? node.base
444
447
  end
445
448
  else
446
- node[:for] == field_or_value.to_s
449
+ #Non element values were handled through the expression filter
450
+ true
447
451
  end
448
452
  end
449
453
 
@@ -416,4 +416,9 @@ Capybara::SpecHelper.spec '#find' do
416
416
  end
417
417
  end
418
418
  end
419
+
420
+ it "should warn if selector type is unknown" do
421
+ expect_any_instance_of(Kernel).to receive(:warn).with(/^Unknown selector type/)
422
+ @session.find(:unknown, '//h1')
423
+ end
419
424
  end
@@ -12,7 +12,11 @@ Capybara::SpecHelper.spec Capybara::Selector do
12
12
  expect(@session.find(:label, for: 'form_other_title')['for']).to eq 'form_other_title'
13
13
  end
14
14
 
15
- it "finds a label from nested input using :for filter" do
15
+ it "finds a label from nested input using :for filter with id string" do
16
+ expect(@session.find(:label, for: 'nested_label').text).to eq 'Nested Label'
17
+ end
18
+
19
+ it "finds a label from nested input using :for filter with element" do
16
20
  input = @session.find(:id, 'nested_label')
17
21
  expect(@session.find(:label, for: input).text).to eq 'Nested Label'
18
22
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Capybara
3
- VERSION = '2.9.1'
3
+ VERSION = '2.9.2'
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.9.1
4
+ version: 2.9.2
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: 2016-09-23 00:00:00.000000000 Z
13
+ date: 2016-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri