capybara 2.8.0 → 2.8.1

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: 0cbea94168c582ba31d25ccf5f24312005b47616
4
- data.tar.gz: 7b779b6363ffb09be883cfe71ac2fde7cd616851
3
+ metadata.gz: fbc8500c466333af5900b64e398ea4bb73221857
4
+ data.tar.gz: f1ccdd60394f1d8d6a73bdc6cc2f70cbd05459f6
5
5
  SHA512:
6
- metadata.gz: 132688050a792bda11f9d4054aa5bac76e6f4070668f72c10bce230060d622e306e9eeb1b2bb079de66d428ca24f2814d07102083619db4e8f53075c473727a6
7
- data.tar.gz: dbd2d43752dad9b40b2281ca1281cd3751e774ba6b785024f98c3c7c845637cdb76c36521343d16f338af34c21439cab00a76f837b32c4a1a88115f52a99e674
6
+ metadata.gz: 1c18871ba8adfa7f8ed70df32f332909cff6d6ee2518fefb252de17267d5549a6a281e6958e3dfb5cda029002be4b51203d0793bbe454e96d7998583a576cd74
7
+ data.tar.gz: 8be99a4f361374e92c9cbb9050920e7c031d4e8cfdcbf1d5fef28cdcfe938df6b61531a817afff9a7910ea9b28b7a0636512420abcdcbedc98fd1dfbcafc25dd
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ #Version 2.8.1
2
+ Release data: 2016-08-25
3
+
4
+ ###Fixed
5
+ * Fixed error message from have_text when text is not found but contains regex special characters [Ryunosuke Sato]
6
+ * Warn when :exact option is passed that has no effect [Thomas Walpole]
7
+
1
8
  # Version 2.8.0
2
9
  Release date: 2016-08-16
3
10
 
@@ -5,7 +12,7 @@ Release date: 2016-08-16
5
12
  * Issue with modals present when closing the page using selenium - Issue #1696 [Jonas Nicklas, Thomas Walpole]
6
13
  * Server errors raised in test code have the cause set to an explanatory exception
7
14
  in rubies that support Exception#cause rather than a confusing ExpectationNotMet - Issue #1719 [Thomas Walpole]
8
- * background/given/given! RSoec aliases will work if RSpec config.shared_context_metadata_behavior == :apply_to_host_groups [Thomas Walpole]
15
+ * background/given/given! RSpec aliases will work if RSpec config.shared_context_metadata_behavior == :apply_to_host_groups [Thomas Walpole]
9
16
  * Fixed setting of unexpectedAlertError now that Selenium will be freezing the Capabilities::DEFAULTS [Thomas Walpole]
10
17
 
11
18
  ### Added
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-webdrvier, stay on Firefox 47.0.1 and selenium-webdriver 2.53.4. Firefox 48 requires geckodriver and is not supported without selenium-webdriver 3 which currently has multiple issues and is feature incomplete
16
+ **Note: Firefox 48** If you're using Firefox with selenium-webdrvier, stay on either Firefox 45.0esr or 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
 
@@ -31,7 +31,7 @@ module Capybara
31
31
  def find(*args)
32
32
  query = Capybara::Queries::SelectorQuery.new(*args)
33
33
  synchronize(query.wait) do
34
- if query.match == :smart or query.match == :prefer_exact
34
+ if (query.match == :smart or query.match == :prefer_exact) and query.supports_exact?
35
35
  result = query.resolve_for(self, true)
36
36
  result = query.resolve_for(self, false) if result.empty? && !query.exact?
37
37
  else
@@ -27,6 +27,9 @@ module Capybara
27
27
  end
28
28
 
29
29
  @expression = @selector.call(@locator)
30
+
31
+ warn_exact_usage
32
+
30
33
  assert_valid_keys
31
34
  end
32
35
 
@@ -79,6 +82,7 @@ module Capybara
79
82
  end
80
83
 
81
84
  def exact?
85
+ return false if !supports_exact?
82
86
  if options.has_key?(:exact)
83
87
  @options[:exact]
84
88
  else
@@ -125,6 +129,11 @@ module Capybara
125
129
  end
126
130
  end
127
131
 
132
+ # @api private
133
+ def supports_exact?
134
+ @expression.respond_to? :to_xpath
135
+ end
136
+
128
137
  private
129
138
 
130
139
  def valid_keys
@@ -150,6 +159,12 @@ module Capybara
150
159
  raise ArgumentError, "invalid option #{match.inspect} for :match, should be one of #{VALID_MATCH.map(&:inspect).join(", ")}"
151
160
  end
152
161
  end
162
+
163
+ def warn_exact_usage
164
+ if options.has_key?(:exact) && !supports_exact?
165
+ warn "The :exact option only has an effect on queries using the XPath#is method. Using it with the query \"#{expression.to_s}\" has no effect."
166
+ end
167
+ end
153
168
  end
154
169
  end
155
170
  end
@@ -48,7 +48,7 @@ module Capybara
48
48
  details_message = []
49
49
 
50
50
  if @node and !@expected_text.is_a? Regexp
51
- insensitive_regexp = Regexp.new(@expected_text, Regexp::IGNORECASE)
51
+ insensitive_regexp = Capybara::Helpers.to_regexp(@expected_text, Regexp::IGNORECASE)
52
52
  insensitive_count = @actual_text.scan(insensitive_regexp).size
53
53
  if insensitive_count != @count
54
54
  details_message << "it was found #{insensitive_count} #{Capybara::Helpers.declension("time", "times", insensitive_count)} using a case insensitive search"
@@ -52,6 +52,13 @@ Capybara::SpecHelper.spec '#assert_text' do
52
52
  end.to raise_error(Capybara::ExpectationNotMet, /it was found 1 time using a case insensitive search/)
53
53
  end
54
54
 
55
+ it "should raise the correct error if requested text is missing but contains regex special characters" do
56
+ @session.visit('/with_html')
57
+ expect do
58
+ @session.assert_text('[]*.')
59
+ end.to raise_error(Capybara::ExpectationNotMet, /expected to find text "\[\]\*\."/)
60
+ end
61
+
55
62
  it "should be true if the text in the page matches given regexp" do
56
63
  @session.visit('/with_html')
57
64
  expect(@session.assert_text(/Lorem/)).to eq(true)
@@ -235,6 +235,12 @@ Capybara::SpecHelper.spec '#find' do
235
235
  Capybara.exact = false
236
236
  @session.find(:xpath, XPath.descendant(:input)[XPath.attr(:id).is("est_fiel")])
237
237
  end
238
+
239
+ it "warns when the option has no effect" do
240
+ expect_any_instance_of(Kernel).to receive(:warn).
241
+ with('The :exact option only has an effect on queries using the XPath#is method. Using it with the query "#test_field" has no effect.')
242
+ @session.find(:css, '#test_field', exact: true)
243
+ end
238
244
  end
239
245
 
240
246
  context "with :match option" do
@@ -292,7 +298,7 @@ Capybara::SpecHelper.spec '#find' do
292
298
  end
293
299
  it "raises an error if there is no match" do
294
300
  expect do
295
- @session.find(:css, ".does-not-exist", :match => :smart, :exact => false)
301
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is("does-not-exist")], :match => :smart, :exact => false)
296
302
  end.to raise_error(Capybara::ElementNotFound)
297
303
  end
298
304
  end
@@ -319,7 +325,7 @@ Capybara::SpecHelper.spec '#find' do
319
325
  end
320
326
  it "raises an error if there is no match" do
321
327
  expect do
322
- @session.find(:css, ".does-not-exist", :match => :smart, :exact => true)
328
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is("does-not-exist")], :match => :smart, :exact => true)
323
329
  end.to raise_error(Capybara::ElementNotFound)
324
330
  end
325
331
  end
@@ -345,7 +351,7 @@ Capybara::SpecHelper.spec '#find' do
345
351
  end
346
352
  it "raises an error if there is no match" do
347
353
  expect do
348
- @session.find(:css, ".does-not-exist", :match => :prefer_exact, :exact => false)
354
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is("does-not-exist")], :match => :prefer_exact, :exact => false)
349
355
  end.to raise_error(Capybara::ElementNotFound)
350
356
  end
351
357
  end
@@ -371,7 +377,7 @@ Capybara::SpecHelper.spec '#find' do
371
377
  end
372
378
  it "raises an error if there is no match" do
373
379
  expect do
374
- @session.find(:css, ".does-not-exist", :match => :prefer_exact, :exact => true)
380
+ @session.find(:xpath, XPath.descendant[XPath.attr(:class).is("does-not-exist")], :match => :prefer_exact, :exact => true)
375
381
  end.to raise_error(Capybara::ElementNotFound)
376
382
  end
377
383
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Capybara
3
- VERSION = '2.8.0'
3
+ VERSION = '2.8.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.8.0
4
+ version: 2.8.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: 2016-08-16 00:00:00.000000000 Z
13
+ date: 2016-08-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri