capybara 2.11.0 → 2.12.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 +30 -4
  3. data/README.md +4 -0
  4. data/lib/capybara.rb +4 -2
  5. data/lib/capybara/driver/base.rb +2 -2
  6. data/lib/capybara/helpers.rb +8 -2
  7. data/lib/capybara/node/actions.rb +52 -1
  8. data/lib/capybara/node/document_matchers.rb +1 -0
  9. data/lib/capybara/node/finders.rb +2 -1
  10. data/lib/capybara/node/matchers.rb +54 -0
  11. data/lib/capybara/node/simple.rb +1 -1
  12. data/lib/capybara/queries/current_path_query.rb +4 -2
  13. data/lib/capybara/queries/selector_query.rb +23 -3
  14. data/lib/capybara/queries/text_query.rb +15 -7
  15. data/lib/capybara/queries/title_query.rb +2 -2
  16. data/lib/capybara/rack_test/form.rb +1 -1
  17. data/lib/capybara/rack_test/node.rb +4 -4
  18. data/lib/capybara/result.rb +2 -2
  19. data/lib/capybara/selector.rb +16 -4
  20. data/lib/capybara/selenium/driver.rb +27 -22
  21. data/lib/capybara/selenium/node.rb +10 -1
  22. data/lib/capybara/session.rb +91 -30
  23. data/lib/capybara/spec/session/accept_prompt_spec.rb +3 -0
  24. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +94 -0
  25. data/lib/capybara/spec/session/assert_current_path.rb +12 -0
  26. data/lib/capybara/spec/session/attach_file_spec.rb +30 -0
  27. data/lib/capybara/spec/session/click_link_spec.rb +12 -1
  28. data/lib/capybara/spec/session/current_url_spec.rb +8 -0
  29. data/lib/capybara/spec/session/evaluate_script_spec.rb +14 -0
  30. data/lib/capybara/spec/session/execute_script_spec.rb +13 -0
  31. data/lib/capybara/spec/session/fill_in_spec.rb +6 -0
  32. data/lib/capybara/spec/session/find_field_spec.rb +2 -0
  33. data/lib/capybara/spec/session/find_spec.rb +3 -3
  34. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +103 -0
  35. data/lib/capybara/spec/session/{within_frame_spec.rb → frame/within_frame_spec.rb} +12 -0
  36. data/lib/capybara/spec/session/has_current_path_spec.rb +28 -0
  37. data/lib/capybara/spec/session/has_selector_spec.rb +21 -0
  38. data/lib/capybara/spec/session/has_text_spec.rb +13 -1
  39. data/lib/capybara/spec/session/has_title_spec.rb +15 -0
  40. data/lib/capybara/spec/session/node_spec.rb +34 -1
  41. data/lib/capybara/spec/session/within_spec.rb +7 -0
  42. data/lib/capybara/spec/spec_helper.rb +4 -0
  43. data/lib/capybara/spec/views/form.erb +48 -0
  44. data/lib/capybara/spec/views/with_js.erb +5 -0
  45. data/lib/capybara/spec/views/within_frames.erb +1 -1
  46. data/lib/capybara/version.rb +1 -1
  47. data/lib/capybara/window.rb +1 -1
  48. data/spec/capybara_spec.rb +2 -2
  49. data/spec/rack_test_spec.rb +10 -0
  50. data/spec/result_spec.rb +3 -3
  51. data/spec/rspec/shared_spec_matchers.rb +1 -1
  52. data/spec/session_spec.rb +10 -0
  53. data/spec/shared_selenium_session.rb +2 -1
  54. data/spec/spec_helper.rb +2 -0
  55. metadata +7 -4
@@ -119,6 +119,13 @@ Capybara::SpecHelper.spec '#within' do
119
119
  end
120
120
  expect(extract_results(@session)['first_name']).to eq('Dagobert')
121
121
  end
122
+
123
+ it "should have #within_element as an alias" do
124
+ expect(Capybara::Session.instance_method(:within)).to eq Capybara::Session.instance_method(:within_element)
125
+ @session.within_element(:css, "#for_foo") do
126
+ expect(@session).not_to have_content('First Name')
127
+ end
128
+ end
122
129
  end
123
130
 
124
131
  Capybara::SpecHelper.spec '#within_fieldset' do
@@ -97,6 +97,10 @@ module Capybara
97
97
  expect(session).to have_xpath("//pre[@id='results']")
98
98
  YAML.load Nokogiri::HTML(session.body).xpath("//pre[@id='results']").first.inner_html.lstrip
99
99
  end
100
+
101
+ def marionette?(session)
102
+ session.driver.respond_to?(:marionette?) && session.driver.marionette?
103
+ end
100
104
  end
101
105
  end
102
106
 
@@ -322,6 +322,9 @@ New line after and before textarea tag
322
322
  Disabled Select
323
323
  <select name="form[disabled_select]" id="form_disabled_select" disabled="disabled">
324
324
  <option value="Should not see me" selected="selected">Should not see me</option>
325
+ <optgroup>
326
+ <option value="Disabled too">Disabled too</option>
327
+ </optgroup>
325
328
  </select>
326
329
  </label>
327
330
  </p>
@@ -343,6 +346,51 @@ New line after and before textarea tag
343
346
  </label>
344
347
  </p>
345
348
 
349
+ <p>
350
+ <fieldset>
351
+ <input name="form[enabled_fieldset_child]" id="form_enabled_fieldset_child"/>
352
+ </fieldset>
353
+ </p>
354
+
355
+
356
+ <p>
357
+ <fieldset disabled="disabled">
358
+ <legend>Disabled Child</legend>
359
+ <input name="form[disabled_fieldset_child]" id="form_disabled_fieldset_child"/>
360
+ <select>
361
+ <option>Disabled Child Option</option>
362
+ </select>
363
+ </fieldset>
364
+
365
+ <fieldset disabled="disabled">
366
+ <legend>
367
+ Nested Disabled
368
+ <input type="checkbox" name="form[disabled_fieldeset_legend_child]" id="form_disabled_fieldset_legend_child"/>
369
+ </legend>
370
+ <legend>
371
+ Another Legend
372
+ <input type="checkbox" name="form[disabled_fieldeset_second_legend_child]" id="form_disabled_fieldset_second_legend_child"/>
373
+ </legend>
374
+ <p>
375
+ <fieldset>
376
+ <input name="form[disabled_fieldset_descendant]" id="form_disabled_fieldset_descendant"/>
377
+ </fieldset>
378
+ </p>
379
+ </fieldset>
380
+ </p>
381
+
382
+ <p>
383
+ <select>
384
+ <optgroup label="Level One">
385
+ <option> A.1 </option>
386
+ </optgroup>
387
+ <optgroup label="Level Two" disabled="disabled">
388
+ <option> A.B.1 </option>
389
+ </optgroup>
390
+ <option> A.2 </option>
391
+ </select>
392
+ </p>
393
+
346
394
  <p>
347
395
  <input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
348
396
  <input type="submit" name="form[awesome]" id="awe123" title="What an Awesome Button" value="awesome"/>
@@ -110,6 +110,11 @@
110
110
  <input type="test" name="with-key-events" id="with-key-events">
111
111
  <p id="key-events-output"></p>
112
112
  </p>
113
+
114
+ <p>
115
+ <input type="file" id="hidden_file" style="opacity:0; display: none;">
116
+ </p>
117
+
113
118
  <script type="text/javascript">
114
119
  // a javascript comment
115
120
  var aVar = 123;
@@ -5,7 +5,7 @@
5
5
  </head>
6
6
  <body>
7
7
  <div id="divInMainWindow">This is the text for divInMainWindow</div>
8
- <iframe src="/frame_one" id="frameOne"></iframe>
8
+ <iframe src="/frame_one" id="frameOne" name="my frame one"></iframe>
9
9
  <iframe src="/frame_two" id="frameTwo"></iframe>
10
10
  <iframe src="/frame_parent" id="parentFrame"></iframe>
11
11
  </body>
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Capybara
3
- VERSION = '2.11.0'
3
+ VERSION = '2.12.0'
4
4
  end
@@ -71,7 +71,7 @@ module Capybara
71
71
  # Get window size.
72
72
  #
73
73
  # @macro about_current
74
- # @return [Array<(Fixnum, Fixnum)>] an array with width and height
74
+ # @return [Array<(Integer, Integer)>] an array with width and height
75
75
  #
76
76
  def size
77
77
  @driver.window_size(handle)
@@ -14,8 +14,8 @@ RSpec.describe Capybara do
14
14
  end
15
15
 
16
16
  it "should be accesible as the deprecated default_wait_time" do
17
- expect_any_instance_of(Kernel).to receive(:warn).once.with('DEPRECATED: #default_wait_time= is deprecated, please use #default_max_wait_time= instead')
18
- expect_any_instance_of(Kernel).to receive(:warn).once.with('DEPRECATED: #default_wait_time is deprecated, please use #default_max_wait_time instead')
17
+ expect(Capybara).to receive(:warn).ordered.with('DEPRECATED: #default_wait_time= is deprecated, please use #default_max_wait_time= instead')
18
+ expect(Capybara).to receive(:warn).ordered.with('DEPRECATED: #default_wait_time is deprecated, please use #default_max_wait_time instead')
19
19
  @previous_default_time = Capybara.default_max_wait_time
20
20
  Capybara.default_wait_time = 5
21
21
  expect(Capybara.default_wait_time).to eq(5)
@@ -112,6 +112,16 @@ RSpec.describe Capybara::Session do
112
112
  end
113
113
  end
114
114
  end
115
+
116
+ describe '#text' do
117
+ it "should return original text content for textareas" do
118
+ @session.visit('/with_html')
119
+ @session.find_field('normal', type: 'textarea', with: 'banana').set('hello')
120
+ normal = @session.find(:css, '#normal')
121
+ expect(normal.value).to eq 'hello'
122
+ expect(normal.text).to eq 'banana'
123
+ end
124
+ end
115
125
  end
116
126
  end
117
127
 
@@ -73,7 +73,7 @@ RSpec.describe Capybara::Result do
73
73
 
74
74
  #Not a great test but it indirectly tests what is needed
75
75
  it "should evaluate filters lazily" do
76
- skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java'
76
+ skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java' && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.1.6.0'))
77
77
  #Not processed until accessed
78
78
  expect(result.instance_variable_get('@result_cache').size).to be 0
79
79
 
@@ -95,7 +95,7 @@ RSpec.describe Capybara::Result do
95
95
 
96
96
  context '#each' do
97
97
  it 'lazily evaluates' do
98
- skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java'
98
+ skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java' && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.1.6.0'))
99
99
  results=[]
100
100
  result.each do |el|
101
101
  results << el
@@ -111,7 +111,7 @@ RSpec.describe Capybara::Result do
111
111
  end
112
112
 
113
113
  it 'lazily evaluates' do
114
- skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java'
114
+ skip 'JRuby has an issue with lazy enumerator next evaluation' if RUBY_PLATFORM == 'java' && (Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('9.1.6.0'))
115
115
  result.each.with_index do |el, idx|
116
116
  expect(result.instance_variable_get('@result_cache').size).to eq(idx+1) # 0 indexing
117
117
  end
@@ -372,7 +372,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|
372
372
  end.to raise_error('expected to find text matching /No such Text/ in "Text"')
373
373
  end
374
374
 
375
- it "casts Fixnum to string" do
375
+ it "casts Integer to string" do
376
376
  expect do
377
377
  expect("<h1>Text</h1>").to have_text(3)
378
378
  end.to raise_error(/expected to find text "3" in "Text"/)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe Capybara::Session do
5
+ it "verifies a passed app is a rack app" do
6
+ expect do
7
+ Capybara::Session.new(:unknown, { random: "hash"})
8
+ end.to raise_error TypeError, "The second parameter to Session::new should be a rack app if passed."
9
+ end
10
+ end
@@ -102,7 +102,8 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
102
102
 
103
103
  context "#fill_in with { clear: Array } fill_options" do
104
104
  it 'should pass the array through to the element' do
105
- #this is mainly for use with [[:ctrl, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
105
+ pending "selenium-webdriver/geckodriver doesn't support complex sets of characters" if @session.driver.marionette?
106
+ #this is mainly for use with [[:control, 'a'], :backspace] - however since that is platform dependant I'm testing with something less useful
106
107
  @session.visit('/form')
107
108
  @session.fill_in('form_first_name', with: 'Harry',
108
109
  fill_options: { clear: [[:shift, 'abc'], :backspace] } )
@@ -5,4 +5,6 @@ require "pry"
5
5
 
6
6
  RSpec.configure do |config|
7
7
  Capybara::SpecHelper.configure(config)
8
+ config.filter_run_including focus_: true unless ENV['TRAVIS']
9
+ config.run_all_when_everything_filtered = true
8
10
  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.11.0
4
+ version: 2.12.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: 2016-12-05 00:00:00.000000000 Z
13
+ date: 2017-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -309,6 +309,7 @@ files:
309
309
  - lib/capybara/spec/session/accept_confirm_spec.rb
310
310
  - lib/capybara/spec/session/accept_prompt_spec.rb
311
311
  - lib/capybara/spec/session/all_spec.rb
312
+ - lib/capybara/spec/session/assert_all_of_selectors_spec.rb
312
313
  - lib/capybara/spec/session/assert_current_path.rb
313
314
  - lib/capybara/spec/session/assert_selector.rb
314
315
  - lib/capybara/spec/session/assert_text.rb
@@ -337,6 +338,8 @@ files:
337
338
  - lib/capybara/spec/session/find_link_spec.rb
338
339
  - lib/capybara/spec/session/find_spec.rb
339
340
  - lib/capybara/spec/session/first_spec.rb
341
+ - lib/capybara/spec/session/frame/switch_to_frame_spec.rb
342
+ - lib/capybara/spec/session/frame/within_frame_spec.rb
340
343
  - lib/capybara/spec/session/go_back_spec.rb
341
344
  - lib/capybara/spec/session/go_forward_spec.rb
342
345
  - lib/capybara/spec/session/has_button_spec.rb
@@ -376,7 +379,6 @@ files:
376
379
  - lib/capybara/spec/session/window/window_spec.rb
377
380
  - lib/capybara/spec/session/window/windows_spec.rb
378
381
  - lib/capybara/spec/session/window/within_window_spec.rb
379
- - lib/capybara/spec/session/within_frame_spec.rb
380
382
  - lib/capybara/spec/session/within_spec.rb
381
383
  - lib/capybara/spec/spec_helper.rb
382
384
  - lib/capybara/spec/test_app.rb
@@ -427,6 +429,7 @@ files:
427
429
  - spec/selenium_spec_firefox.rb
428
430
  - spec/selenium_spec_marionette.rb
429
431
  - spec/server_spec.rb
432
+ - spec/session_spec.rb
430
433
  - spec/shared_selenium_session.rb
431
434
  - spec/spec_helper.rb
432
435
  homepage: https://github.com/teamcapybara/capybara
@@ -449,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
449
452
  version: '0'
450
453
  requirements: []
451
454
  rubyforge_project:
452
- rubygems_version: 2.5.2
455
+ rubygems_version: 2.6.8
453
456
  signing_key:
454
457
  specification_version: 4
455
458
  summary: Capybara aims to simplify the process of integration testing Rack applications,