capybara 3.0.0.rc2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9b394cb5aaa7d6849ba4fd9e486b7fae2298a64f6a5e2f88fd80abea82a2ba6
4
- data.tar.gz: eeca1e3b972c9efb89224fb701a1612a5d503621327af3fb77bf1a028a21761d
3
+ metadata.gz: 8389b150e2b44270ed1d94b8f6e0f48af613f1a2f28b8ad772e35cb7db635ad7
4
+ data.tar.gz: bace2657813bc0681e4586ba2c96a66e824e12651f0e839a8649ed491f0eafa1
5
5
  SHA512:
6
- metadata.gz: 615f9400b993c2408414f886a5cfdd41272e29cb9c3fa1763758888416d3e9c5f42d4d179686f8ac56b185610503aef904be6a508e5e8b7d703760ff85a498a0
7
- data.tar.gz: 0045d33244fdc1cd6615cac65760399088330bc1751781c1ea2c0107570f096f52766841ad2f1a40efb595127e9e78b5c4b1d9341dcd146721eedba0e588062a
6
+ metadata.gz: 5ffed0a0be90e5d8bf022b48d261aa160646562095114ca383a446431ab57403d67a6ccf252129a477484a6ea1bdc1edfefa6930571961e6307b5ce180c6aa30
7
+ data.tar.gz: e5956efba3a7e4a6833a9b63e61c6f136a3210eb77ac44d8b1603b81b6e5bea7bde1ea3fd4c76b8eda6a10f61c1e0e805aef7f8aa4bcf801061c46a7fded1c02
data/History.md CHANGED
@@ -1,3 +1,16 @@
1
+ # Version 3.0.0
2
+ Release date: 2018-04-05
3
+
4
+ ### Changed
5
+
6
+ * Selenium driver only closes extra windows for browsers where that is known to work (Firefox, Chrome)
7
+ * "threadsafe" mode is no longer considered beta
8
+
9
+ ### Fixes
10
+
11
+ * Multiple file attach_file with Firefox
12
+ * Use Puma::Server directly rather than Rack::Handler::Puma so signal handlers don't prevent test quitting
13
+
1
14
  # Version 3.0.0.rc2
2
15
  Release date: 2018-03-23
3
16
 
@@ -30,7 +43,7 @@ Release date: 2018-03-02
30
43
  ### Removed
31
44
 
32
45
  * Ruby < 2.2.2 support
33
- * `Capybara.exact_options` no longer exists. Just use `exact:true` on relevant actions/finders if necessary.
46
+ * `Capybara.exact_options` no longer exists. Just use `exact: true` on relevant actions/finders if necessary.
34
47
  * All previously deprecated methods removed
35
48
  * RSpec 2.x support
36
49
  * selenium-webdriver 2.x support
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jnicklas/capybara?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8
8
 
9
9
  **Note** You are viewing the README for the development version of Capybara. If you are using the current release version
10
- you can find the README at https://github.com/teamcapybara/capybara/blob/2.17_stable/README.md
10
+ you can find the README at https://github.com/teamcapybara/capybara/blob/3.0_stable/README.md
11
11
 
12
12
 
13
13
  Capybara helps you test web applications by simulating how a real user would
@@ -76,7 +76,7 @@ GitHub): http://groups.google.com/group/ruby-capybara
76
76
 
77
77
  ## <a name="setup"></a>Setup
78
78
 
79
- Capybara requires Ruby 2.2.0 or later. To install, add this line to your
79
+ Capybara requires Ruby 2.2.2 or later. To install, add this line to your
80
80
  `Gemfile` and run `bundle install`:
81
81
 
82
82
  ```ruby
@@ -151,15 +151,15 @@ If you are using Rails, put your Capybara specs in `spec/features` or `spec/syst
151
151
  if [you have it configured in
152
152
  RSpec](https://www.relishapp.com/rspec/rspec-rails/docs/upgrade#file-type-inference-disabled))
153
153
  and if you have your Capybara specs in a different directory, then tag the
154
- example groups with `:type => :feature` or `:type => :system` depending on which type of test you're writing.
154
+ example groups with `type: :feature` or `type: :system` depending on which type of test you're writing.
155
155
 
156
156
  If you are not using Rails, tag all the example groups in which you want to use
157
- Capybara with `:type => :feature`.
157
+ Capybara with `type: :feature`.
158
158
 
159
159
  You can now write your specs like so:
160
160
 
161
161
  ```ruby
162
- describe "the signin process", :type => :feature do
162
+ describe "the signin process", type: :feature do
163
163
  before :each do
164
164
  User.make(email: 'user@example.com', password: 'password')
165
165
  end
@@ -183,7 +183,7 @@ to one specific driver. For example:
183
183
  ```ruby
184
184
  describe 'some stuff which requires js', js: true do
185
185
  it 'will use the default js driver'
186
- it 'will switch to one specific driver', :driver => :webkit
186
+ it 'will switch to one specific driver', driver: :webkit
187
187
  end
188
188
  ```
189
189
 
@@ -219,7 +219,7 @@ feature "Signing in" do
219
219
  end
220
220
  ```
221
221
 
222
- `feature` is in fact just an alias for `describe ..., :type => :feature`,
222
+ `feature` is in fact just an alias for `describe ..., type:> :feature`,
223
223
  `background` is an alias for `before`, `scenario` for `it`, and
224
224
  `given`/`given!` aliases for `let`/`let!`, respectively.
225
225
 
@@ -1047,7 +1047,7 @@ additional info about how the underlying driver can be configured.
1047
1047
  are testing for specific server errors and using multiple sessions make sure to test for the
1048
1048
  errors using the initial session (usually :default)
1049
1049
 
1050
- ## <a name="threadsafe"></a>"Threadsafe" mode - BETA - may change
1050
+ ## <a name="threadsafe"></a>"Threadsafe" mode
1051
1051
 
1052
1052
  In normal mode most of Capybara's configuration options are global settings which can cause issues
1053
1053
  if using multiple sessions and wanting to change a setting for only one of the sessions. To provide
@@ -439,7 +439,22 @@ end
439
439
 
440
440
  Capybara.register_server :puma do |app, port, host, **options|
441
441
  require 'rack/handler/puma'
442
- Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
442
+ # If we just run the Puma Rack handler it installs signal handlers which prevent us from being able to interrupt tests.
443
+ # Therefore construct and run the Server instance ourselves.
444
+ # Rack::Handler::Puma.run(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
445
+
446
+ conf = Rack::Handler::Puma.config(app, { Host: host, Port: port, Threads: "0:4", workers: 0, daemon: false }.merge(options))
447
+ events = conf.options[:Silent] ? ::Puma::Events.strings : ::Puma::Events.stdio
448
+
449
+ events.log "Capybara starting Puma..."
450
+ events.log "* Version #{Puma::Const::PUMA_VERSION} , codename: #{Puma::Const::CODE_NAME}"
451
+ events.log "* Min threads: #{conf.options[:min_threads]}, max threads: #{conf.options[:max_threads]}"
452
+
453
+ Puma::Server.new(conf.app, events, conf.options).tap do |s|
454
+ s.binder.parse conf.options[:binds], s.events
455
+ s.min_threads = conf.options[:min_threads]
456
+ s.max_threads = conf.options[:max_threads]
457
+ end.run.join
443
458
  end
444
459
 
445
460
  Capybara.configure do |config|
@@ -25,7 +25,6 @@ module Capybara
25
25
  attr_writer :reuse_server
26
26
 
27
27
  def threadsafe=(bool)
28
- warn "Capybara.threadsafe == true is a BETA feature and may change in future minor versions" if bool
29
28
  raise "Threadsafe setting cannot be changed once a session is created" if (bool != threadsafe) && Session.instance_created?
30
29
  @threadsafe = bool
31
30
  end
@@ -264,7 +264,8 @@ module Capybara
264
264
  raise unless allow_label_click && catch_error?(e)
265
265
  begin
266
266
  el ||= find(selector, locator, options.merge(visible: :all))
267
- find(:label, for: el, visible: true).click unless el.checked? == checked
267
+ res = find(:label, for: el, visible: true).click unless el.checked? == checked
268
+ res
268
269
  rescue # swallow extra errors - raise original
269
270
  raise e
270
271
  end
@@ -26,7 +26,6 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
26
26
  @w3c = ((defined?(Selenium::WebDriver::Remote::W3CCapabilities) && @browser.capabilities.is_a?(Selenium::WebDriver::Remote::W3CCapabilities)) ||
27
27
  (defined?(Selenium::WebDriver::Remote::W3C::Capabilities) && @browser.capabilities.is_a?(Selenium::WebDriver::Remote::W3C::Capabilities)))
28
28
  main = Process.pid
29
- @primary_window_handle = current_window_handle
30
29
 
31
30
  at_exit do
32
31
  # Store the exit status of the test run since it goes away after calling the at_exit proc...
@@ -110,8 +109,10 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
110
109
  # Use instance variable directly so we avoid starting the browser just to reset the session
111
110
  return unless @browser
112
111
 
113
- switch_to_window(@primary_window_handle)
114
- window_handles.reject { |handle| handle == @primary_window_handle }.each { |win| close_window(win) }
112
+ if firefox? || chrome?
113
+ switch_to_window(window_handles.first)
114
+ window_handles.slice(1..-1).each { |win| close_window(win) }
115
+ end
115
116
 
116
117
  navigated = false
117
118
  start_time = Capybara::Helpers.monotonic_time
@@ -210,7 +211,7 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
210
211
  end
211
212
 
212
213
  def close_window(handle)
213
- raise ArgumentError, "Not allowed to close the primary window" if handle == @primary_window_handle
214
+ raise ArgumentError, "Not allowed to close the primary window" if handle == window_handles.first
214
215
  within_given_window(handle) do
215
216
  browser.close
216
217
  end
@@ -269,7 +270,10 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
269
270
  ::Selenium::WebDriver::Error::ElementNotInteractableError,
270
271
  ::Selenium::WebDriver::Error::ElementClickInterceptedError,
271
272
  ::Selenium::WebDriver::Error::InvalidElementStateError,
272
- ::Selenium::WebDriver::Error::ElementNotSelectableError
273
+ ::Selenium::WebDriver::Error::ElementNotSelectableError,
274
+ ::Selenium::WebDriver::Error::ElementNotSelectableError,
275
+ ::Selenium::WebDriver::Error::NoSuchElementError, # IE
276
+ ::Selenium::WebDriver::Error::InvalidArgumentError # IE
273
277
  ]
274
278
  end
275
279
 
@@ -297,6 +301,11 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
297
301
  browser_name == "edge"
298
302
  end
299
303
 
304
+ # @api private
305
+ def ie?
306
+ browser_name == "ie"
307
+ end
308
+
300
309
  private
301
310
 
302
311
  def browser_name
@@ -279,10 +279,11 @@ private
279
279
 
280
280
  def set_file(value) # rubocop:disable Naming/AccessorMethodName
281
281
  path_names = value.to_s.empty? ? [] : value
282
- if driver.chrome?
283
- native.send_keys(Array(path_names).join("\n"))
282
+ if driver.marionette?
283
+ native.clear
284
+ Array(path_names).each { |p| native.send_keys(p) }
284
285
  else
285
- native.send_keys(*path_names)
286
+ native.send_keys(Array(path_names).join("\n"))
286
287
  end
287
288
  end
288
289
 
@@ -73,7 +73,6 @@ Capybara::SpecHelper.spec "#attach_file" do
73
73
  end
74
74
 
75
75
  it "should not break when using HTML5 multiple file input uploading multiple files" do
76
- pending "Selenium is buggy on this, see http://code.google.com/p/selenium/issues/detail?id=2239" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium_(firefox|marionette)/
77
76
  @session.attach_file("Multiple Documents",
78
77
  [@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
79
78
  @session.click_button('Upload Multiple')
@@ -86,6 +85,16 @@ Capybara::SpecHelper.spec "#attach_file" do
86
85
  @session.click_button('Upload Empty Multiple')
87
86
  expect(@session).to have_content("Successfully ignored empty file field")
88
87
  end
88
+
89
+ it "should not append files to already attached" do
90
+ @session.attach_file "Multiple Documents", with_os_path_separators(@test_file_path)
91
+ @session.attach_file("Multiple Documents",
92
+ [@test_file_path, @another_test_file_path].map { |f| with_os_path_separators(f) })
93
+ @session.click_button('Upload Multiple')
94
+ expect(@session.body).to include("2 | ") # number of files
95
+ expect(@session.body).to include(File.read(@test_file_path))
96
+ expect(@session.body).to include(File.read(@another_test_file_path))
97
+ end
89
98
  end
90
99
 
91
100
  context "with a locator that doesn't exist" do
@@ -169,7 +169,7 @@ Capybara::SpecHelper.spec '#click_button' do
169
169
  end
170
170
  end
171
171
 
172
- context "with fields associated with the form using the form attribute" do
172
+ context "with fields associated with the form using the form attribute", requires: [:form_attribute] do
173
173
  before do
174
174
  @session.click_button('submit_form1')
175
175
  @results = extract_results(@session)
@@ -192,7 +192,7 @@ Capybara::SpecHelper.spec '#click_button' do
192
192
  end
193
193
  end
194
194
 
195
- context "with submit button outside the form defined by <button> tag" do
195
+ context "with submit button outside the form defined by <button> tag", requires: [:form_attribute] do
196
196
  before do
197
197
  @session.click_button('outside_button')
198
198
  @results = extract_results(@session)
@@ -208,7 +208,7 @@ Capybara::SpecHelper.spec '#click_button' do
208
208
  end
209
209
  end
210
210
 
211
- context "with submit button outside the form defined by <input type='submit'> tag" do
211
+ context "with submit button outside the form defined by <input type='submit'> tag", requires: [:form_attribute] do
212
212
  before do
213
213
  @session.click_button('outside_submit')
214
214
  @results = extract_results(@session)
@@ -224,7 +224,7 @@ Capybara::SpecHelper.spec '#click_button' do
224
224
  end
225
225
  end
226
226
 
227
- context "with submit button for form1 located within form2" do
227
+ context "with submit button for form1 located within form2", requires: [:form_attribute] do
228
228
  it "should submit the form associated with the button" do
229
229
  @session.click_button('other_form_button')
230
230
  expect(extract_results(@session)['which_form']).to eq("form1")
@@ -18,7 +18,7 @@ Capybara::SpecHelper.spec '#refresh' do
18
18
  end
19
19
 
20
20
  it "it reposts" do
21
- if marionette?(@session) || edge?(@session)
21
+ if marionette?(@session) || edge?(@session) || ie?(@session)
22
22
  skip "Firefox and Edge insist on prompting without providing a way to suppress"
23
23
  end
24
24
  @session.visit('/form')
@@ -137,6 +137,10 @@ module Capybara
137
137
  def edge?(session)
138
138
  session.respond_to?(:driver) && session.driver.respond_to?(:edge?, true) && session.driver.send(:edge?)
139
139
  end
140
+
141
+ def ie?(session)
142
+ session.respond_to?(:driver) && session.driver.respond_to?(:ie?, true) && session.driver.send(:ie?)
143
+ end
140
144
  end
141
145
  end
142
146
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.0.0.rc2'.freeze
4
+ VERSION = '3.0.0'.freeze
5
5
  end
@@ -56,27 +56,11 @@ RSpec.describe Capybara do
56
56
  end
57
57
 
58
58
  it "should have :webrick registered" do
59
- require 'rack/handler/webrick'
60
- mock_app = double('app')
61
- Capybara.server = :webrick
62
- expect(Rack::Handler::WEBrick).to receive(:run)
63
- Capybara.server.call(mock_app, 8000)
59
+ expect(Capybara.servers[:webrick]).not_to be_nil
64
60
  end
65
61
 
66
62
  it "should have :puma registered" do
67
- require 'rack/handler/puma'
68
- mock_app = double('app')
69
- Capybara.server = :puma
70
- expect(Rack::Handler::Puma).to receive(:run).with(mock_app, hash_including(Host: nil, Port: 8000))
71
- Capybara.server.call(mock_app, 8000)
72
- end
73
-
74
- it "should pass options to server" do
75
- require 'rack/handler/puma'
76
- mock_app = double('app')
77
- Capybara.server = :puma, { Silent: true }
78
- expect(Rack::Handler::Puma).to receive(:run).with(mock_app, hash_including(Host: nil, Port: 9000, Silent: true))
79
- Capybara.server.call(mock_app, 9000)
63
+ expect(Capybara.servers[:puma]).not_to be_nil
80
64
  end
81
65
  end
82
66
 
@@ -26,7 +26,6 @@ RSpec.describe 'Capybara RSpec Matchers', type: :feature do
26
26
 
27
27
  not_to_msg = error_msg_for { expect(page).not_to have_text('This is a test') }
28
28
  have_no_msg = error_msg_for { expect(page).to have_no_text('This is a test') }
29
- puts not_to_msg
30
29
  expect(not_to_msg).to eq have_no_msg
31
30
  end
32
31
  end
@@ -20,7 +20,7 @@ $stdout.puts `#{Selenium::WebDriver::Edge.driver_path} --version` if ENV['CI']
20
20
 
21
21
  Capybara::SpecHelper.run_specs TestSessions::SeleniumEdge, "selenium", capybara_skip: skipped_tests
22
22
 
23
- RSpec.describe "Capybara::Session with Edge" do
23
+ RSpec.describe "Capybara::Session with Edge", capybara_skip: skipped_tests do
24
24
  include Capybara::SpecHelper
25
25
  include_examples "Capybara::Session", TestSessions::SeleniumEdge, :selenium_edge
26
26
  include_examples Capybara::RSpecMatchers, TestSessions::SeleniumEdge, :selenium_edge
@@ -7,21 +7,25 @@ require 'rspec/shared_spec_matchers'
7
7
 
8
8
  Capybara.register_driver :selenium_ie do |app|
9
9
  # ::Selenium::WebDriver.logger.level = "debug"
10
- Capybara::Selenium::Driver.new(app, browser: :ie)
10
+ Capybara::Selenium::Driver.new(
11
+ app,
12
+ browser: :ie,
13
+ desired_capabilities: ::Selenium::WebDriver::Remote::Capabilities.ie('requireWindowFocus': true)
14
+ )
11
15
  end
12
16
 
13
17
  module TestSessions
14
18
  SeleniumIE = Capybara::Session.new(:selenium_ie, TestApp)
15
19
  end
16
20
 
17
- skipped_tests = %i[response_headers status_code trigger]
21
+ skipped_tests = %i[response_headers status_code trigger modals hover form_attribute windows]
18
22
 
19
23
  $stdout.puts `#{Selenium::WebDriver::IE.driver_path} --version` if ENV['CI']
20
24
 
21
25
  Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, "selenium", capybara_skip: skipped_tests
22
26
 
23
- RSpec.describe "Capybara::Session with Internet Explorer" do
27
+ RSpec.describe "Capybara::Session with Internet Explorer", capybara_skip: skipped_tests do
24
28
  include Capybara::SpecHelper
25
- include_examples "Capybara::Session", TestSessions::SeleniumIE, :selenium_ie
26
- include_examples Capybara::RSpecMatchers, TestSessions::SeleniumIE, :selenium_ie
29
+ include_examples "Capybara::Session", TestSessions::SeleniumIE, :selenium_ie
30
+ include_examples Capybara::RSpecMatchers, TestSessions::SeleniumIE, :selenium_ie
27
31
  end
@@ -55,7 +55,7 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
55
55
  end
56
56
  end
57
57
 
58
- describe "#accept_alert" do
58
+ describe "#accept_alert", requires: [:modals] do
59
59
  it "supports a blockless mode" do
60
60
  @session.visit('/with_js')
61
61
  @session.click_link('Open alert')
@@ -64,7 +64,6 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
64
64
  end
65
65
 
66
66
  it "can be called before visiting" do
67
- skip "Edge driver doesn't get any interactions when alert is set" if edge?(@session)
68
67
  @session.accept_alert "Initial alert" do
69
68
  @session.visit('/initial_alert')
70
69
  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: 3.0.0.rc2
4
+ version: 3.0.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-03-23 00:00:00.000000000 Z
13
+ date: 2018-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -495,9 +495,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
495
495
  version: 2.2.2
496
496
  required_rubygems_version: !ruby/object:Gem::Requirement
497
497
  requirements:
498
- - - ">"
498
+ - - ">="
499
499
  - !ruby/object:Gem::Version
500
- version: 1.3.1
500
+ version: '0'
501
501
  requirements: []
502
502
  rubyforge_project:
503
503
  rubygems_version: 2.7.6