capybara 3.1.1 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +19 -0
  3. data/README.md +1 -1
  4. data/lib/capybara.rb +2 -0
  5. data/lib/capybara/config.rb +2 -1
  6. data/lib/capybara/driver/base.rb +1 -1
  7. data/lib/capybara/driver/node.rb +3 -3
  8. data/lib/capybara/node/actions.rb +90 -92
  9. data/lib/capybara/node/base.rb +2 -2
  10. data/lib/capybara/node/document_matchers.rb +5 -5
  11. data/lib/capybara/node/element.rb +47 -16
  12. data/lib/capybara/node/finders.rb +13 -13
  13. data/lib/capybara/node/matchers.rb +18 -17
  14. data/lib/capybara/node/simple.rb +6 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +3 -3
  17. data/lib/capybara/queries/current_path_query.rb +1 -1
  18. data/lib/capybara/queries/match_query.rb +8 -0
  19. data/lib/capybara/queries/selector_query.rb +97 -42
  20. data/lib/capybara/queries/sibling_query.rb +1 -1
  21. data/lib/capybara/queries/text_query.rb +12 -7
  22. data/lib/capybara/rack_test/browser.rb +9 -7
  23. data/lib/capybara/rack_test/form.rb +15 -17
  24. data/lib/capybara/rack_test/node.rb +12 -12
  25. data/lib/capybara/result.rb +26 -15
  26. data/lib/capybara/rspec.rb +1 -2
  27. data/lib/capybara/rspec/compound.rb +4 -4
  28. data/lib/capybara/rspec/matchers.rb +2 -2
  29. data/lib/capybara/selector.rb +75 -225
  30. data/lib/capybara/selector/css.rb +2 -2
  31. data/lib/capybara/selector/filter_set.rb +17 -21
  32. data/lib/capybara/selector/filters/base.rb +24 -1
  33. data/lib/capybara/selector/filters/expression_filter.rb +3 -5
  34. data/lib/capybara/selector/filters/node_filter.rb +4 -4
  35. data/lib/capybara/selector/selector.rb +221 -69
  36. data/lib/capybara/selenium/driver.rb +15 -88
  37. data/lib/capybara/selenium/node.rb +25 -28
  38. data/lib/capybara/server.rb +10 -54
  39. data/lib/capybara/server/animation_disabler.rb +43 -0
  40. data/lib/capybara/server/middleware.rb +55 -0
  41. data/lib/capybara/session.rb +29 -30
  42. data/lib/capybara/session/config.rb +11 -1
  43. data/lib/capybara/session/matchers.rb +5 -5
  44. data/lib/capybara/spec/session/assert_text_spec.rb +1 -1
  45. data/lib/capybara/spec/session/body_spec.rb +10 -12
  46. data/lib/capybara/spec/session/click_link_spec.rb +3 -3
  47. data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +1 -1
  48. data/lib/capybara/spec/session/fill_in_spec.rb +9 -0
  49. data/lib/capybara/spec/session/find_field_spec.rb +1 -1
  50. data/lib/capybara/spec/session/find_spec.rb +8 -3
  51. data/lib/capybara/spec/session/has_link_spec.rb +2 -2
  52. data/lib/capybara/spec/session/node_spec.rb +50 -0
  53. data/lib/capybara/spec/session/node_wrapper_spec.rb +5 -5
  54. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +1 -1
  55. data/lib/capybara/spec/session/window/windows_spec.rb +3 -5
  56. data/lib/capybara/spec/spec_helper.rb +4 -2
  57. data/lib/capybara/spec/views/with_animation.erb +46 -0
  58. data/lib/capybara/version.rb +1 -1
  59. data/lib/capybara/window.rb +3 -2
  60. data/spec/filter_set_spec.rb +19 -2
  61. data/spec/result_spec.rb +33 -1
  62. data/spec/rspec/features_spec.rb +6 -10
  63. data/spec/rspec/shared_spec_matchers.rb +4 -4
  64. data/spec/selector_spec.rb +74 -4
  65. data/spec/selenium_spec_marionette.rb +2 -0
  66. data/spec/server_spec.rb +1 -1
  67. data/spec/session_spec.rb +12 -0
  68. data/spec/shared_selenium_session.rb +30 -0
  69. metadata +8 -9
  70. data/.yard/templates_custom/default/class/html/selectors.erb +0 -38
  71. data/.yard/templates_custom/default/class/html/setup.rb +0 -17
  72. data/.yard/yard_extensions.rb +0 -78
  73. data/.yardopts +0 -1
@@ -35,7 +35,7 @@ RSpec.describe Capybara::Server do
35
35
  ensure
36
36
  Capybara.server_host = nil
37
37
  end
38
- end unless ENV['TRAVIS'] && (RUBY_ENGINE == 'jruby') or Gem.win_platform?
38
+ end unless (ENV['TRAVIS'] && (RUBY_ENGINE == 'jruby')) || Gem.win_platform?
39
39
 
40
40
  it "should use specified port" do
41
41
  Capybara.server_port = 22789
@@ -18,6 +18,12 @@ RSpec.describe Capybara::Session do
18
18
  end
19
19
 
20
20
  context "current_driver" do
21
+ around do |example|
22
+ orig_driver = Capybara.current_driver
23
+ example.run
24
+ Capybara.current_driver = orig_driver
25
+ end
26
+
21
27
  it "is global when threadsafe false" do
22
28
  Capybara.threadsafe = false
23
29
  Capybara.current_driver = :selenium
@@ -40,6 +46,12 @@ RSpec.describe Capybara::Session do
40
46
  end
41
47
 
42
48
  context "session_name" do
49
+ around do |example|
50
+ orig_name = Capybara.session_name
51
+ example.run
52
+ Capybara.session_name = orig_name
53
+ end
54
+
43
55
  it "is global when threadsafe false" do
44
56
  Capybara.threadsafe = false
45
57
  Capybara.session_name = "sess1"
@@ -88,6 +88,13 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
88
88
  expect(session.find(:fillable_field, 'form_first_name').value).to eq('Harry')
89
89
  end
90
90
 
91
+ it 'should fill in if the option is set via global option' do
92
+ Capybara.default_set_options = { clear: :backspace }
93
+ session.visit('/form')
94
+ session.fill_in('form_first_name', with: 'Thomas')
95
+ expect(session.find(:fillable_field, 'form_first_name').value).to eq('Thomas')
96
+ end
97
+
91
98
  it 'should only trigger onchange once' do
92
99
  session.visit('/with_js')
93
100
  session.fill_in('with_change_event',
@@ -249,6 +256,29 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
249
256
  end.to raise_error(ArgumentError, 'Not allowed to close the primary window')
250
257
  end
251
258
  end
259
+
260
+ context "AnimationDisabler" do
261
+ before(:context) do # rubocop:disable RSpec/BeforeAfterAll
262
+ Capybara.disable_animation = true
263
+ @animation_session = Capybara::Session.new(session.mode, TestApp.new)
264
+ end
265
+
266
+ after(:context) do # rubocop:disable RSpec/BeforeAfterAll
267
+ Capybara.disable_animation = false
268
+ end
269
+
270
+ it "should disable CSS transitions" do
271
+ @animation_session.visit('with_animation')
272
+ @animation_session.click_link('transition me away')
273
+ expect(@animation_session).to have_no_link('transition me away', wait: 0.5)
274
+ end
275
+
276
+ it "should disable CSS animations", :focus_ do
277
+ @animation_session.visit('with_animation')
278
+ @animation_session.click_link('animate me away')
279
+ expect(@animation_session).to have_no_link('animate me away', wait: 0.5)
280
+ end
281
+ end
252
282
  end
253
283
 
254
284
  def headless_or_remote?
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: 3.1.1
4
+ version: 3.2.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: 2018-05-25 00:00:00.000000000 Z
13
+ date: 2018-06-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -88,14 +88,14 @@ dependencies:
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '3.0'
91
+ version: '3.1'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '3.0'
98
+ version: '3.1'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: cucumber
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -271,10 +271,6 @@ executables: []
271
271
  extensions: []
272
272
  extra_rdoc_files: []
273
273
  files:
274
- - ".yard/templates_custom/default/class/html/selectors.erb"
275
- - ".yard/templates_custom/default/class/html/setup.rb"
276
- - ".yard/yard_extensions.rb"
277
- - ".yardopts"
278
274
  - History.md
279
275
  - License.txt
280
276
  - README.md
@@ -326,6 +322,8 @@ files:
326
322
  - lib/capybara/selenium/driver.rb
327
323
  - lib/capybara/selenium/node.rb
328
324
  - lib/capybara/server.rb
325
+ - lib/capybara/server/animation_disabler.rb
326
+ - lib/capybara/server/middleware.rb
329
327
  - lib/capybara/session.rb
330
328
  - lib/capybara/session/config.rb
331
329
  - lib/capybara/session/matchers.rb
@@ -437,6 +435,7 @@ files:
437
435
  - lib/capybara/spec/views/popup_two.erb
438
436
  - lib/capybara/spec/views/postback.erb
439
437
  - lib/capybara/spec/views/tables.erb
438
+ - lib/capybara/spec/views/with_animation.erb
440
439
  - lib/capybara/spec/views/with_base_tag.erb
441
440
  - lib/capybara/spec/views/with_count.erb
442
441
  - lib/capybara/spec/views/with_fixed_header_footer.erb
@@ -495,7 +494,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
495
494
  requirements:
496
495
  - - ">="
497
496
  - !ruby/object:Gem::Version
498
- version: 2.2.2
497
+ version: 2.3.0
499
498
  required_rubygems_version: !ruby/object:Gem::Requirement
500
499
  requirements:
501
500
  - - ">="
@@ -1,38 +0,0 @@
1
- <div id="selectors">
2
- <h2>Built-in Selectors</h2>
3
- <ul>
4
- <% @selectors.each do |name, selector| %>
5
- <li>
6
- <h3>:<%= name %></h3>
7
- <div class="docstring">
8
- <div class="discussion">
9
- <p><%= h(selector.docstring) %></p>
10
- </div>
11
- </div>
12
- <div class="tags">
13
- <p class="inline">Locator:</p>
14
- <% if locator=selector.tag('locator') %>
15
- <p class="inline"><%= h locator.text %></p>
16
- <% end %>
17
- <% if selector.has_tag?('filter') %>
18
- <p>Filters:</p>
19
- <ul class="param">
20
- <% selector.tags('filter').each do |filter| %>
21
- <li>
22
- <span class="name"><%= filter.name %></span>
23
- <% if filter.types %>
24
- <span class="type">(<tt><%= h(filter.types.join(', ')) %></tt>)</span>
25
- <% end %>
26
- <% if filter.text %>
27
-
28
- <div class="inline"><p><%= h filter.text %></p></div>
29
- <% end %>
30
- </li>
31
- <% end %>
32
- </ul>
33
- <% end %>
34
- </div
35
- </li>
36
- <% end %>
37
- </ul>
38
- </div>
@@ -1,17 +0,0 @@
1
- def init
2
- super
3
- sections.place(:builtins).before(:subclasses)
4
- end
5
-
6
- def builtins
7
- return if object.path != "Capybara::Selector" # only show built-in selectors for Selector class
8
-
9
- @selectors = Registry.all(:selector)
10
- return if @selectors.nil? || @selectors.empty?
11
-
12
- @selectors = @selectors.map do |selector|
13
- [selector.name, selector]
14
- end
15
-
16
- erb(:selectors)
17
- end
@@ -1,78 +0,0 @@
1
- YARD::Templates::Engine.register_template_path Pathname.new('./.yard/templates_custom')
2
-
3
- YARD::Tags::Library.define_tag "Locator", :locator
4
- YARD::Tags::Library.define_tag "Filter", :filter, :with_types_and_name
5
-
6
- class SelectorObject < YARD::CodeObjects::Base
7
- def path
8
- "__Capybara" + sep + super
9
- end
10
- end
11
-
12
- class AddSelectorHandler < YARD::Handlers::Ruby::Base
13
- handles method_call(:add_selector)
14
- namespace_only
15
- process do
16
- name = statement.parameters.first.jump(:tstring_content, :ident).source
17
- # object = YARD::CodeObjects::MethodObject.new(namespace, name.to_sym)
18
- # object = SelectorObject.new(YARD::Registry.resolve(P("Capybara"), "#add_selector", false, true), name.to_sym)
19
- object = SelectorObject.new(namespace, name)
20
- register(object)
21
- parse_block(statement.last.last, :owner => object)
22
-
23
- # modify the object
24
- object.dynamic = true
25
- end
26
- end
27
-
28
- class AddExpressionFilterHandler < YARD::Handlers::Ruby::Base
29
- handles method_call(:xpath)
30
- handles method_call(:css)
31
-
32
- process do
33
- return unless owner.is_a?(SelectorObject)
34
- return if statement.parameters.empty?
35
- # names = statement.parameters.children.map { |p| p.jump(:tstring_content, :ident).source.sub(/^:/, '') }
36
- names = statement.parameters.children.map &:source
37
- current_names = owner.tags(:filter).map(&:name)
38
- (names-current_names).each do |name|
39
- owner.add_tag(YARD::Tags::Tag.new(:filter, nil, nil, name))
40
- end
41
- end
42
- end
43
-
44
- class AddFilterHandler < YARD::Handlers::Ruby::Base
45
- handles method_call(:filter)
46
-
47
- process do
48
- return unless owner.is_a?(SelectorObject)
49
- return if statement.parameters.empty?
50
- name = statement.parameters.first.source
51
- type = if statement.parameters[1] && statement.parameters[1].source == ':boolean'
52
- 'Boolean'
53
- else
54
- nil
55
- end
56
- if owner.tags(:filter).none? {|tag| tag.name == name }
57
- filter_tag = YARD::Tags::Tag.new(:filter, nil, type, name)
58
- owner.add_tag(filter_tag)
59
- end
60
- end
61
- end
62
-
63
- class FilterSetHandler < YARD::Handlers::Ruby::Base
64
- handles method_call(:filter_set)
65
-
66
- process do
67
- return unless owner.is_a?(SelectorObject)
68
- return if statement.parameters.empty? || !statement.parameters[1]
69
-
70
- names = statement.parameters[1].flatten.map { |name| ":#{name}" }
71
- names.each do |name|
72
- if owner.tags(:filter).none? {|tag| tag.name == name }
73
- filter_tag = YARD::Tags::Tag.new(:filter, nil, nil, name)
74
- owner.add_tag(filter_tag)
75
- end
76
- end
77
- end
78
- end
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --load ./.yard/yard_extensions.rb