capybara 2.14.4 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +17 -0
  3. data/README.md +14 -22
  4. data/lib/capybara.rb +16 -4
  5. data/lib/capybara/config.rb +12 -2
  6. data/lib/capybara/driver/base.rb +4 -0
  7. data/lib/capybara/node/finders.rb +79 -16
  8. data/lib/capybara/queries/ancestor_query.rb +25 -0
  9. data/lib/capybara/queries/selector_query.rb +4 -1
  10. data/lib/capybara/queries/sibling_query.rb +25 -0
  11. data/lib/capybara/rack_test/browser.rb +5 -0
  12. data/lib/capybara/rack_test/driver.rb +5 -1
  13. data/lib/capybara/rack_test/form.rb +1 -3
  14. data/lib/capybara/rack_test/node.rb +1 -1
  15. data/lib/capybara/rspec/compound.rb +95 -0
  16. data/lib/capybara/rspec/matchers.rb +4 -1
  17. data/lib/capybara/selector.rb +1 -0
  18. data/lib/capybara/selector/filter.rb +13 -41
  19. data/lib/capybara/selector/filter_set.rb +12 -5
  20. data/lib/capybara/selector/filters/base.rb +33 -0
  21. data/lib/capybara/selector/filters/expression_filter.rb +40 -0
  22. data/lib/capybara/selector/filters/node_filter.rb +27 -0
  23. data/lib/capybara/selector/selector.rb +4 -4
  24. data/lib/capybara/selenium/driver.rb +12 -2
  25. data/lib/capybara/selenium/node.rb +70 -55
  26. data/lib/capybara/session.rb +65 -41
  27. data/lib/capybara/spec/session/ancestor_spec.rb +85 -0
  28. data/lib/capybara/spec/session/attach_file_spec.rb +1 -1
  29. data/lib/capybara/spec/session/check_spec.rb +4 -4
  30. data/lib/capybara/spec/session/choose_spec.rb +2 -2
  31. data/lib/capybara/spec/session/click_button_spec.rb +1 -1
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +3 -3
  33. data/lib/capybara/spec/session/click_link_spec.rb +1 -1
  34. data/lib/capybara/spec/session/fill_in_spec.rb +2 -2
  35. data/lib/capybara/spec/session/find_spec.rb +1 -1
  36. data/lib/capybara/spec/session/refresh_spec.rb +28 -0
  37. data/lib/capybara/spec/session/select_spec.rb +2 -2
  38. data/lib/capybara/spec/session/sibling_spec.rb +52 -0
  39. data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
  40. data/lib/capybara/spec/session/unselect_spec.rb +2 -2
  41. data/lib/capybara/spec/session/window/become_closed_spec.rb +3 -3
  42. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +11 -9
  43. data/lib/capybara/spec/session/window/within_window_spec.rb +27 -2
  44. data/lib/capybara/spec/test_app.rb +3 -1
  45. data/lib/capybara/spec/views/with_html.erb +27 -1
  46. data/lib/capybara/spec/views/with_windows.erb +4 -0
  47. data/lib/capybara/version.rb +1 -1
  48. data/spec/capybara_spec.rb +9 -1
  49. data/spec/minitest_spec_spec.rb +1 -1
  50. data/spec/rspec/shared_spec_matchers.rb +146 -42
  51. data/spec/selenium_spec_chrome.rb +12 -16
  52. data/spec/selenium_spec_marionette.rb +2 -0
  53. data/spec/shared_selenium_session.rb +2 -0
  54. metadata +14 -6
  55. data/lib/capybara/selector/expression_filter.rb +0 -40
@@ -3,38 +3,34 @@ require 'spec_helper'
3
3
  require 'selenium-webdriver'
4
4
  require 'shared_selenium_session'
5
5
 
6
- chrome_options = {
7
- browser: :chrome,
8
- options: ::Selenium::WebDriver::Chrome::Options.new(args: ENV['TRAVIS'] ? ['no-sandbox' ] : [])
9
- }
10
-
11
- if ENV['CAPYBARA_CHROME_HEADLESS']
12
- chrome_options[:options].args << 'headless'
13
- Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
14
- end
6
+ CHROME_DRIVER = if ENV['HEADLESS'] then :selenium_chrome_headless else :selenium_chrome end
15
7
 
16
- Capybara.register_driver :selenium_chrome do |app|
17
- Capybara::Selenium::Driver.new(app, chrome_options)
8
+ if ENV['HEADLESS'] && ENV['TRAVIS']
9
+ Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta'
18
10
  end
19
11
 
20
12
  Capybara.register_driver :selenium_chrome_clear_storage do |app|
13
+ chrome_options = {
14
+ browser: :chrome,
15
+ options: ::Selenium::WebDriver::Chrome::Options.new()
16
+ }
17
+ chrome_options[:options].args << 'headless' if ENV['HEADLESS']
21
18
  Capybara::Selenium::Driver.new(app, chrome_options.merge(clear_local_storage: true, clear_session_storage: true))
22
19
  end
23
20
 
24
21
  module TestSessions
25
- Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
22
+ Chrome = Capybara::Session.new(CHROME_DRIVER, TestApp)
26
23
  end
27
24
 
28
25
  skipped_tests = [:response_headers, :status_code, :trigger]
29
- skipped_tests << :windows if ENV['TRAVIS'] && ENV['SKIP_WINDOW']
30
26
  # skip window tests when headless for now - closing a window not supported by chromedriver/chrome
31
- skipped_tests << :windows if ENV['TRAVIS'] && ENV['CAPYBARA_CHROME_HEADLESS']
27
+ skipped_tests << :windows if ENV['TRAVIS'] && (ENV['SKIP_WINDOW'] || ENV['HEADLESS'])
32
28
 
33
- Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", capybara_skip: skipped_tests
29
+ Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_DRIVER.to_s, capybara_skip: skipped_tests
34
30
 
35
31
  RSpec.describe "Capybara::Session with chrome" do
36
32
  include Capybara::SpecHelper
37
- include_examples "Capybara::Session", TestSessions::Chrome, :selenium_chrome
33
+ include_examples "Capybara::Session", TestSessions::Chrome, CHROME_DRIVER
38
34
 
39
35
  context "storage" do
40
36
  describe "#reset!" do
@@ -4,6 +4,8 @@ require "selenium-webdriver"
4
4
  require 'shared_selenium_session'
5
5
  require 'rspec/shared_spec_matchers'
6
6
 
7
+ ENV['MOZ_HEADLESS']='1' if ENV['HEADLESS']
8
+
7
9
  Capybara.register_driver :selenium_marionette do |app|
8
10
  Capybara::Selenium::Driver.new(
9
11
  app,
@@ -43,11 +43,13 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
43
43
  end
44
44
 
45
45
  it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
46
+ skip if ENV['HEADLESS']
46
47
  system(@env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
47
48
  expect($?.exitstatus).to eq(1)
48
49
  end
49
50
 
50
51
  it "should have return code 0 when running selenium_driver_rspec_success.rb" do
52
+ skip if ENV['HEADLESS']
51
53
  system(@env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
52
54
  expect($?.exitstatus).to eq(0)
53
55
  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.14.4
4
+ version: 2.15.0
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-06-27 00:00:00.000000000 Z
13
+ date: 2017-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -27,19 +27,19 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  version: 1.3.3
29
29
  - !ruby/object:Gem::Dependency
30
- name: mime-types
30
+ name: mini_mime
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '1.16'
35
+ version: 0.1.3
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '1.16'
42
+ version: 0.1.3
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rack
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -309,10 +309,12 @@ files:
309
309
  - lib/capybara/node/finders.rb
310
310
  - lib/capybara/node/matchers.rb
311
311
  - lib/capybara/node/simple.rb
312
+ - lib/capybara/queries/ancestor_query.rb
312
313
  - lib/capybara/queries/base_query.rb
313
314
  - lib/capybara/queries/current_path_query.rb
314
315
  - lib/capybara/queries/match_query.rb
315
316
  - lib/capybara/queries/selector_query.rb
317
+ - lib/capybara/queries/sibling_query.rb
316
318
  - lib/capybara/queries/text_query.rb
317
319
  - lib/capybara/queries/title_query.rb
318
320
  - lib/capybara/query.rb
@@ -324,14 +326,17 @@ files:
324
326
  - lib/capybara/rails.rb
325
327
  - lib/capybara/result.rb
326
328
  - lib/capybara/rspec.rb
329
+ - lib/capybara/rspec/compound.rb
327
330
  - lib/capybara/rspec/features.rb
328
331
  - lib/capybara/rspec/matcher_proxies.rb
329
332
  - lib/capybara/rspec/matchers.rb
330
333
  - lib/capybara/selector.rb
331
334
  - lib/capybara/selector/css.rb
332
- - lib/capybara/selector/expression_filter.rb
333
335
  - lib/capybara/selector/filter.rb
334
336
  - lib/capybara/selector/filter_set.rb
337
+ - lib/capybara/selector/filters/base.rb
338
+ - lib/capybara/selector/filters/expression_filter.rb
339
+ - lib/capybara/selector/filters/node_filter.rb
335
340
  - lib/capybara/selector/selector.rb
336
341
  - lib/capybara/selenium/driver.rb
337
342
  - lib/capybara/selenium/node.rb
@@ -349,6 +354,7 @@ files:
349
354
  - lib/capybara/spec/session/accept_confirm_spec.rb
350
355
  - lib/capybara/spec/session/accept_prompt_spec.rb
351
356
  - lib/capybara/spec/session/all_spec.rb
357
+ - lib/capybara/spec/session/ancestor_spec.rb
352
358
  - lib/capybara/spec/session/assert_all_of_selectors_spec.rb
353
359
  - lib/capybara/spec/session/assert_current_path.rb
354
360
  - lib/capybara/spec/session/assert_selector.rb
@@ -396,6 +402,7 @@ files:
396
402
  - lib/capybara/spec/session/headers.rb
397
403
  - lib/capybara/spec/session/html_spec.rb
398
404
  - lib/capybara/spec/session/node_spec.rb
405
+ - lib/capybara/spec/session/refresh_spec.rb
399
406
  - lib/capybara/spec/session/reset_session_spec.rb
400
407
  - lib/capybara/spec/session/response_code.rb
401
408
  - lib/capybara/spec/session/save_and_open_page_spec.rb
@@ -405,6 +412,7 @@ files:
405
412
  - lib/capybara/spec/session/screenshot_spec.rb
406
413
  - lib/capybara/spec/session/select_spec.rb
407
414
  - lib/capybara/spec/session/selectors_spec.rb
415
+ - lib/capybara/spec/session/sibling_spec.rb
408
416
  - lib/capybara/spec/session/source_spec.rb
409
417
  - lib/capybara/spec/session/text_spec.rb
410
418
  - lib/capybara/spec/session/title_spec.rb
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'capybara/selector/filter'
3
-
4
- module Capybara
5
- class Selector
6
- class ExpressionFilter < Filter
7
- undef_method :matches?
8
-
9
- def apply_filter(expr, value)
10
- return expr if skip?(value)
11
-
12
- if !valid_value?(value)
13
- msg = "Invalid value #{value.inspect} passed to expression filter #{@name} - "
14
- if default?
15
- warn msg + "defaulting to #{default}"
16
- value = default
17
- else
18
- warn msg + "skipping"
19
- return expr
20
- end
21
- end
22
-
23
- @block.call(expr, value)
24
- end
25
- end
26
-
27
- class IdentityExpressionFilter < ExpressionFilter
28
- def initialize
29
- end
30
-
31
- def default?
32
- false
33
- end
34
-
35
- def apply_filter(expr, _value)
36
- return expr
37
- end
38
- end
39
- end
40
- end