capybara 2.18.0 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -1
  3. data/README.md +12 -12
  4. data/lib/capybara.rb +13 -25
  5. data/lib/capybara/config.rb +11 -57
  6. data/lib/capybara/cucumber.rb +2 -3
  7. data/lib/capybara/driver/base.rb +5 -16
  8. data/lib/capybara/driver/node.rb +5 -4
  9. data/lib/capybara/dsl.rb +1 -0
  10. data/lib/capybara/helpers.rb +16 -28
  11. data/lib/capybara/minitest.rb +139 -138
  12. data/lib/capybara/minitest/spec.rb +15 -14
  13. data/lib/capybara/node/actions.rb +59 -81
  14. data/lib/capybara/node/base.rb +11 -18
  15. data/lib/capybara/node/document.rb +2 -2
  16. data/lib/capybara/node/document_matchers.rb +8 -8
  17. data/lib/capybara/node/element.rb +30 -40
  18. data/lib/capybara/node/finders.rb +62 -70
  19. data/lib/capybara/node/matchers.rb +48 -71
  20. data/lib/capybara/node/simple.rb +11 -17
  21. data/lib/capybara/queries/ancestor_query.rb +4 -6
  22. data/lib/capybara/queries/base_query.rb +18 -17
  23. data/lib/capybara/queries/current_path_query.rb +8 -24
  24. data/lib/capybara/queries/match_query.rb +3 -7
  25. data/lib/capybara/queries/selector_query.rb +92 -95
  26. data/lib/capybara/queries/sibling_query.rb +4 -4
  27. data/lib/capybara/queries/text_query.rb +37 -34
  28. data/lib/capybara/queries/title_query.rb +8 -11
  29. data/lib/capybara/rack_test/browser.rb +15 -18
  30. data/lib/capybara/rack_test/css_handlers.rb +6 -4
  31. data/lib/capybara/rack_test/driver.rb +6 -10
  32. data/lib/capybara/rack_test/form.rb +50 -40
  33. data/lib/capybara/rack_test/node.rb +70 -56
  34. data/lib/capybara/rails.rb +2 -6
  35. data/lib/capybara/result.rb +22 -22
  36. data/lib/capybara/rspec.rb +5 -10
  37. data/lib/capybara/rspec/compound.rb +5 -10
  38. data/lib/capybara/rspec/features.rb +17 -48
  39. data/lib/capybara/rspec/matcher_proxies.rb +31 -15
  40. data/lib/capybara/rspec/matchers.rb +70 -60
  41. data/lib/capybara/selector.rb +129 -117
  42. data/lib/capybara/selector/css.rb +6 -11
  43. data/lib/capybara/selector/filter.rb +1 -17
  44. data/lib/capybara/selector/filter_set.rb +17 -14
  45. data/lib/capybara/selector/filters/base.rb +7 -6
  46. data/lib/capybara/selector/filters/expression_filter.rb +6 -23
  47. data/lib/capybara/selector/filters/node_filter.rb +2 -12
  48. data/lib/capybara/selector/selector.rb +27 -33
  49. data/lib/capybara/selenium/driver.rb +113 -127
  50. data/lib/capybara/selenium/node.rb +148 -113
  51. data/lib/capybara/server.rb +3 -2
  52. data/lib/capybara/session.rb +137 -223
  53. data/lib/capybara/session/config.rb +47 -67
  54. data/lib/capybara/session/matchers.rb +8 -7
  55. data/lib/capybara/spec/public/test.js +26 -4
  56. data/lib/capybara/spec/session/accept_alert_spec.rb +1 -0
  57. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -2
  58. data/lib/capybara/spec/session/accept_prompt_spec.rb +1 -0
  59. data/lib/capybara/spec/session/all_spec.rb +31 -18
  60. data/lib/capybara/spec/session/ancestor_spec.rb +2 -4
  61. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +6 -5
  62. data/lib/capybara/spec/session/assert_current_path.rb +12 -11
  63. data/lib/capybara/spec/session/assert_selector.rb +1 -0
  64. data/lib/capybara/spec/session/assert_text.rb +18 -17
  65. data/lib/capybara/spec/session/assert_title.rb +1 -0
  66. data/lib/capybara/spec/session/attach_file_spec.rb +14 -13
  67. data/lib/capybara/spec/session/body_spec.rb +1 -0
  68. data/lib/capybara/spec/session/check_spec.rb +7 -6
  69. data/lib/capybara/spec/session/choose_spec.rb +5 -4
  70. data/lib/capybara/spec/session/click_button_spec.rb +20 -28
  71. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -7
  72. data/lib/capybara/spec/session/click_link_spec.rb +8 -7
  73. data/lib/capybara/spec/session/current_scope_spec.rb +4 -3
  74. data/lib/capybara/spec/session/current_url_spec.rb +7 -6
  75. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
  76. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -0
  77. data/lib/capybara/spec/session/element/assert_match_selector.rb +1 -1
  78. data/lib/capybara/spec/session/element/match_xpath_spec.rb +1 -1
  79. data/lib/capybara/spec/session/element/matches_selector_spec.rb +5 -5
  80. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +3 -2
  81. data/lib/capybara/spec/session/evaluate_script_spec.rb +4 -3
  82. data/lib/capybara/spec/session/execute_script_spec.rb +4 -3
  83. data/lib/capybara/spec/session/fill_in_spec.rb +6 -5
  84. data/lib/capybara/spec/session/find_button_spec.rb +4 -3
  85. data/lib/capybara/spec/session/find_by_id_spec.rb +2 -1
  86. data/lib/capybara/spec/session/find_field_spec.rb +8 -14
  87. data/lib/capybara/spec/session/find_link_spec.rb +6 -5
  88. data/lib/capybara/spec/session/find_spec.rb +37 -31
  89. data/lib/capybara/spec/session/first_spec.rb +60 -33
  90. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -1
  91. data/lib/capybara/spec/session/frame/within_frame_spec.rb +9 -16
  92. data/lib/capybara/spec/session/go_back_spec.rb +1 -0
  93. data/lib/capybara/spec/session/go_forward_spec.rb +1 -0
  94. data/lib/capybara/spec/session/has_all_selectors_spec.rb +15 -15
  95. data/lib/capybara/spec/session/has_button_spec.rb +2 -1
  96. data/lib/capybara/spec/session/has_css_spec.rb +3 -2
  97. data/lib/capybara/spec/session/has_current_path_spec.rb +12 -28
  98. data/lib/capybara/spec/session/has_field_spec.rb +4 -3
  99. data/lib/capybara/spec/session/has_link_spec.rb +1 -0
  100. data/lib/capybara/spec/session/has_none_selectors_spec.rb +17 -17
  101. data/lib/capybara/spec/session/has_select_spec.rb +30 -29
  102. data/lib/capybara/spec/session/has_selector_spec.rb +5 -4
  103. data/lib/capybara/spec/session/has_table_spec.rb +2 -1
  104. data/lib/capybara/spec/session/has_text_spec.rb +6 -5
  105. data/lib/capybara/spec/session/has_title_spec.rb +1 -0
  106. data/lib/capybara/spec/session/has_xpath_spec.rb +1 -0
  107. data/lib/capybara/spec/session/headers.rb +2 -1
  108. data/lib/capybara/spec/session/html_spec.rb +1 -0
  109. data/lib/capybara/spec/session/node_spec.rb +91 -56
  110. data/lib/capybara/spec/session/node_wrapper_spec.rb +36 -0
  111. data/lib/capybara/spec/session/refresh_spec.rb +4 -2
  112. data/lib/capybara/spec/session/reset_session_spec.rb +1 -0
  113. data/lib/capybara/spec/session/response_code.rb +1 -0
  114. data/lib/capybara/spec/session/save_and_open_page_spec.rb +1 -0
  115. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +6 -11
  116. data/lib/capybara/spec/session/save_page_spec.rb +1 -17
  117. data/lib/capybara/spec/session/save_screenshot_spec.rb +1 -1
  118. data/lib/capybara/spec/session/select_spec.rb +20 -20
  119. data/lib/capybara/spec/session/selectors_spec.rb +2 -2
  120. data/lib/capybara/spec/session/sibling_spec.rb +1 -1
  121. data/lib/capybara/spec/session/text_spec.rb +1 -0
  122. data/lib/capybara/spec/session/title_spec.rb +1 -1
  123. data/lib/capybara/spec/session/uncheck_spec.rb +4 -3
  124. data/lib/capybara/spec/session/unselect_spec.rb +6 -5
  125. data/lib/capybara/spec/session/visit_spec.rb +9 -3
  126. data/lib/capybara/spec/session/window/become_closed_spec.rb +2 -1
  127. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -0
  128. data/lib/capybara/spec/session/window/open_new_window_spec.rb +1 -0
  129. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +2 -1
  130. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -1
  131. data/lib/capybara/spec/session/window/window_spec.rb +12 -12
  132. data/lib/capybara/spec/session/window/windows_spec.rb +2 -3
  133. data/lib/capybara/spec/session/window/within_window_spec.rb +13 -68
  134. data/lib/capybara/spec/session/within_spec.rb +1 -0
  135. data/lib/capybara/spec/spec_helper.rb +26 -18
  136. data/lib/capybara/spec/test_app.rb +8 -9
  137. data/lib/capybara/spec/views/form.erb +1 -0
  138. data/lib/capybara/spec/views/with_html.erb +3 -1
  139. data/lib/capybara/spec/views/within_frames.erb +4 -1
  140. data/lib/capybara/version.rb +2 -1
  141. data/lib/capybara/window.rb +6 -10
  142. data/spec/basic_node_spec.rb +1 -0
  143. data/spec/capybara_spec.rb +9 -32
  144. data/spec/dsl_spec.rb +5 -13
  145. data/spec/filter_set_spec.rb +5 -4
  146. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -1
  147. data/spec/fixtures/selenium_driver_rspec_success.rb +3 -2
  148. data/spec/minitest_spec.rb +4 -3
  149. data/spec/minitest_spec_spec.rb +3 -2
  150. data/spec/per_session_config_spec.rb +9 -8
  151. data/spec/rack_test_spec.rb +21 -20
  152. data/spec/result_spec.rb +17 -16
  153. data/spec/rspec/features_spec.rb +17 -14
  154. data/spec/rspec/scenarios_spec.rb +5 -7
  155. data/spec/rspec/shared_spec_matchers.rb +96 -99
  156. data/spec/rspec/views_spec.rb +2 -1
  157. data/spec/rspec_matchers_spec.rb +19 -2
  158. data/spec/rspec_spec.rb +11 -15
  159. data/spec/selector_spec.rb +5 -6
  160. data/spec/selenium_spec_chrome.rb +7 -4
  161. data/spec/selenium_spec_marionette.rb +26 -12
  162. data/spec/server_spec.rb +33 -33
  163. data/spec/session_spec.rb +2 -1
  164. data/spec/shared_selenium_session.rb +27 -21
  165. data/spec/spec_helper.rb +2 -5
  166. metadata +66 -87
  167. data/lib/capybara/query.rb +0 -7
  168. data/spec/selenium_spec_firefox.rb +0 -68
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
3
4
  before(:each) do
4
5
  @window = @session.current_window
@@ -38,8 +39,8 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
38
39
  it "returns value from the block" do
39
40
  window = (@session.windows - [@window]).first
40
41
  value = @session.within_window window do
41
- 43252003274489856000
42
- end
42
+ 43252003274489856000
43
+ end
43
44
  expect(value).to eq(43252003274489856000)
44
45
  end
45
46
 
@@ -57,7 +58,7 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
57
58
  expect(@session.send(:scopes)).to eq([nil])
58
59
  end
59
60
 
60
- it "should leave correct scopes after execution in case of error", requires: [:windows, :frames] do
61
+ it "should leave correct scopes after execution in case of error", requires: %i[windows frames] do
61
62
  window = (@session.windows - [@window]).first
62
63
  expect do
63
64
  @session.within_frame 'frameOne' do
@@ -87,25 +88,25 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
87
88
 
88
89
  context "with lambda" do
89
90
  it "should find the div in another window" do
90
- @session.within_window(->{ @session.title == 'Title of the first popup'}) do
91
+ @session.within_window(-> { @session.title == 'Title of the first popup' }) do
91
92
  expect(@session).to have_css('#divInPopupOne')
92
93
  end
93
94
  end
94
95
 
95
96
  it "should find divs in both windows" do
96
- @session.within_window(->{ @session.title == 'Title of popup two'}) do
97
+ @session.within_window(-> { @session.title == 'Title of popup two' }) do
97
98
  expect(@session).to have_css('#divInPopupTwo')
98
99
  end
99
- @session.within_window(->{ @session.title == 'Title of the first popup'}) do
100
+ @session.within_window(-> { @session.title == 'Title of the first popup' }) do
100
101
  expect(@session).to have_css('#divInPopupOne')
101
102
  end
102
103
  expect(@session.title).to eq('With Windows')
103
104
  end
104
105
 
105
106
  it "should be able to nest within_window" do
106
- @session.within_window(->{ @session.title == 'Title of popup two'}) do
107
+ @session.within_window(-> { @session.title == 'Title of popup two' }) do
107
108
  expect(@session).to have_css('#divInPopupTwo')
108
- @session.within_window(->{ @session.title == 'Title of the first popup'}) do
109
+ @session.within_window(-> { @session.title == 'Title of the first popup' }) do
109
110
  expect(@session).to have_css('#divInPopupOne')
110
111
  end
111
112
  expect(@session).to have_css('#divInPopupTwo')
@@ -119,7 +120,7 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
119
120
  it "should work inside a normal scope" do
120
121
  expect(@session).to have_css('#openWindow')
121
122
  @session.within(:css, '#scope') do
122
- @session.within_window(->{ @session.title == 'Title of the first popup'}) do
123
+ @session.within_window(-> { @session.title == 'Title of the first popup' }) do
123
124
  expect(@session).to have_css('#divInPopupOne')
124
125
  end
125
126
  expect(@session).to have_content('My scoped content')
@@ -129,7 +130,7 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
129
130
 
130
131
  it "should raise error if window wasn't found" do
131
132
  expect do
132
- @session.within_window(->{ @session.title == 'Invalid title'}) do
133
+ @session.within_window(-> { @session.title == 'Invalid title' }) do
133
134
  expect(@session).to have_css('#divInPopupOne')
134
135
  end
135
136
  end.to raise_error(Capybara::WindowError, "Could not find a window matching block/lambda")
@@ -139,15 +140,13 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
139
140
  end
140
141
 
141
142
  it "returns value from the block" do
142
- value = @session.within_window(->{ @session.title == 'Title of popup two'}) do
143
- 42
144
- end
143
+ value = @session.within_window(-> { @session.title == 'Title of popup two' }) { 42 }
145
144
  expect(value).to eq(42)
146
145
  end
147
146
 
148
147
  it "should switch back if exception was raised inside block" do
149
148
  expect do
150
- @session.within_window(->{ @session.title == 'Title of popup two'}) do
149
+ @session.within_window(-> { @session.title == 'Title of popup two' }) do
151
150
  raise 'some error'
152
151
  end
153
152
  end.to raise_error(StandardError, 'some error')
@@ -155,58 +154,4 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
155
154
  expect(@session.send(:scopes)).to eq([nil])
156
155
  end
157
156
  end
158
-
159
- context "with string" do
160
- it "should warn" do
161
- expect(@session).to receive(:warn).with(/DEPRECATION WARNING/).and_call_original
162
- @session.within_window('firstPopup') {}
163
- end
164
-
165
- it "should find window by handle" do
166
- window = (@session.windows - [@window]).first
167
- @session.within_window window.handle do
168
- expect(@session).to have_title(/Title of the first popup|Title of popup two/)
169
- end
170
- end
171
-
172
- it "should find the div in firstPopup" do
173
- @session.within_window("firstPopup") do
174
- expect(@session.find("//*[@id='divInPopupOne']").text).to eq 'This is the text of divInPopupOne'
175
- end
176
- end
177
- it "should find the div in secondPopup" do
178
- @session.within_window("secondPopup") do
179
- expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
180
- end
181
- end
182
- it "should find the divs in both popups" do
183
- @session.within_window("secondPopup") do
184
- expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
185
- end
186
- @session.within_window("firstPopup") do
187
- expect(@session.find("//*[@id='divInPopupOne']").text).to eq 'This is the text of divInPopupOne'
188
- end
189
- end
190
- it "should find the div in the main window after finding a div in a popup" do
191
- @session.within_window("secondPopup") do
192
- expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
193
- end
194
- expect(@session.find("//*[@id='doesNotOpenWindows']").text).to eq 'Does not open windows'
195
- end
196
- it "should reset scope when switching windows" do
197
- @session.within(:css, '#doesNotOpenWindows') do
198
- @session.within_window("secondPopup") do
199
- expect(@session.find("//*[@id='divInPopupTwo']").text).to eq 'This is the text of divInPopupTwo'
200
- end
201
- end
202
- end
203
- it "should switch back if exception was raised inside block" do
204
- expect do
205
- @session.within_window('secondPopup') do
206
- raise 'some error'
207
- end
208
- end.to raise_error(StandardError, 'some error')
209
- expect(@session.current_window).to eq(@window)
210
- end
211
- end
212
157
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Capybara::SpecHelper.spec '#within' do
3
4
  before do
4
5
  @session.visit('/with_scope')
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "rspec"
3
4
  require "rspec/expectations"
4
5
  require "capybara"
@@ -6,15 +7,6 @@ require "capybara/rspec" # Required here instead of in rspec_spec to avoid RSpec
6
7
  require "capybara/spec/test_app"
7
8
  require "nokogiri"
8
9
 
9
- # Alias be_truthy/be_falsey if not already defined to be able to use in RSpec 2 and 3
10
- unless RSpec::Matchers.method_defined?(:be_truthy)
11
- RSpec::Matchers.module_eval do
12
- alias be_truthy be_true
13
- alias be_falsey be_false
14
- alias be_falsy be_false
15
- end
16
- end
17
-
18
10
  module Capybara
19
11
  module SpecHelper
20
12
  class << self
@@ -33,13 +25,9 @@ module Capybara
33
25
  Capybara.default_max_wait_time = 1
34
26
  Capybara.ignore_hidden_elements = true
35
27
  Capybara.exact = false
36
- # `exact_options` is deprecated - set instancce var directly so we
37
- # don't generate message every reset
38
- Capybara.send(:config).session_options.instance_variable_set('@exact_options', false)
39
28
  Capybara.raise_server_errors = true
40
29
  Capybara.visible_text_only = false
41
30
  Capybara.match = :smart
42
- Capybara.wait_on_first_by_default = false
43
31
  Capybara.enable_aria_label = false
44
32
  reset_threadsafe
45
33
  end
@@ -59,7 +47,7 @@ module Capybara
59
47
  @specs << [name, options, block]
60
48
  end
61
49
 
62
- def run_specs(session, name, options={})
50
+ def run_specs(session, name, **options)
63
51
  specs = @specs
64
52
  RSpec.describe Capybara::Session, name, options do
65
53
  include Capybara::SpecHelper
@@ -80,6 +68,10 @@ module Capybara
80
68
  SpecHelper.reset_threadsafe(false, @session)
81
69
  end
82
70
 
71
+ before :each, :exact_false do
72
+ Capybara.exact = false
73
+ end
74
+
83
75
  specs.each do |spec_name, spec_options, block|
84
76
  describe spec_name, *spec_options do
85
77
  class_eval(&block)
@@ -94,7 +86,7 @@ module Capybara
94
86
  session = session.current_session if session.respond_to?(:current_session)
95
87
  session.instance_variable_set(:@config, nil) if session
96
88
  end
97
- end # class << self
89
+ end
98
90
 
99
91
  def silence_stream(stream)
100
92
  old_stream = stream.dup
@@ -119,11 +111,27 @@ module Capybara
119
111
  end
120
112
 
121
113
  def marionette?(session)
122
- session.driver.respond_to?(:marionette?, true) && session.driver.send(:marionette?)
114
+ session.respond_to?(:driver) && session.driver.respond_to?(:marionette?, true) && session.driver.send(:marionette?)
115
+ end
116
+
117
+ def marionette_lt?(version, session)
118
+ marionette?(session) && (session.driver.browser.capabilities[:browser_version].to_f < version)
119
+ end
120
+
121
+ def marionette_gte?(version, session)
122
+ marionette?(session) && (session.driver.browser.capabilities[:browser_version].to_f >= version)
123
+ end
124
+
125
+ def chrome?(session)
126
+ session.respond_to?(:driver) && session.driver.respond_to?(:chrome?, true) && session.driver.send(:chrome?)
127
+ end
128
+
129
+ def chrome_lt?(version, session)
130
+ chrome?(session) && (session.driver.browser.capabilities[:version].to_f < version)
123
131
  end
124
132
 
125
- def rspec2?
126
- !defined?(::RSpec::Expectations::Version) || (Gem::Version.new(RSpec::Expectations::Version::STRING) < Gem::Version.new('3.0'))
133
+ def chrome_gte?(version, session)
134
+ chrome?(session) && (session.driver.browser.capabilities[:version].to_f >= version)
127
135
  end
128
136
  end
129
137
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'sinatra/base'
3
4
  require 'tilt/erb'
4
5
  require 'rack'
@@ -21,7 +22,7 @@ class TestApp < Sinatra::Base
21
22
  # Also check lib/capybara/spec/views/*.erb for pages not listed here
22
23
 
23
24
  get '/' do
24
- response.set_cookie('capybara', { value: 'root cookie', domain: request.host, path: request.path} )
25
+ response.set_cookie('capybara', value: 'root cookie', domain: request.host, path: request.path)
25
26
  'Hello world! <a href="with_html">Relative</a>'
26
27
  end
27
28
 
@@ -38,8 +39,8 @@ class TestApp < Sinatra::Base
38
39
  end
39
40
 
40
41
  get '/referer_base' do
41
- '<a href="/get_referer">direct link</a>' +
42
- '<a href="/redirect_to_get_referer">link via redirect</a>' +
42
+ '<a href="/get_referer">direct link</a>' \
43
+ '<a href="/redirect_to_get_referer">link via redirect</a>' \
43
44
  '<form action="/get_referer" method="get"><input type="submit"></form>'
44
45
  end
45
46
 
@@ -69,7 +70,7 @@ class TestApp < Sinatra::Base
69
70
  end
70
71
 
71
72
  get '/with-quotes' do
72
- %q{"No," he said, "you can't do that."}
73
+ %q("No," he said, "you can't do that.")
73
74
  end
74
75
 
75
76
  get '/form/get' do
@@ -149,7 +150,7 @@ class TestApp < Sinatra::Base
149
150
 
150
151
  post '/form' do
151
152
  @@form_post_count += 1
152
- '<pre id="results">' + params[:form].merge({"post_count" => @@form_post_count}).to_yaml + '</pre>'
153
+ '<pre id="results">' + params[:form].merge("post_count" => @@form_post_count).to_yaml + '</pre>'
153
154
  end
154
155
 
155
156
  post '/upload_empty' do
@@ -173,7 +174,7 @@ class TestApp < Sinatra::Base
173
174
 
174
175
  post '/upload_multiple' do
175
176
  begin
176
- buffer = ["#{params[:form][:multiple_documents].size}"]
177
+ buffer = [params[:form][:multiple_documents].size.to_s]
177
178
  params[:form][:multiple_documents].each do |doc|
178
179
  buffer << "Content-type: #{doc[:type]}"
179
180
  buffer << "File content: #{doc[:tempfile].read}"
@@ -185,6 +186,4 @@ class TestApp < Sinatra::Base
185
186
  end
186
187
  end
187
188
 
188
- if __FILE__ == $0
189
- Rack::Handler::WEBrick.run TestApp, Port: 8070
190
- end
189
+ Rack::Handler::Puma.run TestApp, Port: 8070 if $PROGRAM_NAME == __FILE__
@@ -186,6 +186,7 @@ New line after and before textarea tag
186
186
  <input type="checkbox" value="pagani" name="form[cars][]" id="form_cars_pagani" style="position: absolute; left: -9999px"/>
187
187
  <label for="form_cars_pagani">Pagani</label>
188
188
  <input type="checkbox" value="ariel" name="form[cars][]" id="form_cars_ariel" style="display: none"/>
189
+ <input type="checkbox" value="porsche" name="form[cars][]" id="form_cars_porsche" checked="checked" style="display: none"/>
189
190
  <label>
190
191
  McLaren
191
192
  <input type="checkbox" value="mclaren" name="form[cars][]" id="form_cars_mclaren" style="display: none"/>
@@ -150,4 +150,6 @@ banana</textarea>
150
150
  <div data-pre=true>Pre Sibling</div>
151
151
  <div data-post=true>Post Sibling</div>
152
152
  </div>
153
- </div>
153
+ </div>
154
+
155
+ <div id='1escape.me' class="2escape">needs escaping</div>
@@ -4,7 +4,10 @@
4
4
  <title>With Frames</title>
5
5
  </head>
6
6
  <body>
7
- <div id="divInMainWindow">This is the text for divInMainWindow</div>
7
+ <div id="divInMainWindow">
8
+ This is the text for divInMainWindow
9
+ <iframe src="/frame_parent" id="innerParentFrame"></iframe>
10
+ </div>
8
11
  <iframe src="/frame_one" id="frameOne" name="my frame one"></iframe>
9
12
  <iframe src="/frame_two" id="frameTwo"></iframe>
10
13
  <iframe src="/frame_parent" id="parentFrame"></iframe>
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Capybara
3
- VERSION = '2.18.0'
4
+ VERSION = '3.0.0.rc1'.freeze
4
5
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Capybara
3
4
  ##
4
5
  # The Window class represents a browser window.
@@ -101,7 +102,7 @@ module Capybara
101
102
  end
102
103
 
103
104
  def eql?(other)
104
- other.kind_of?(self.class) && @session == other.session && @handle == other.handle
105
+ other.is_a?(self.class) && @session == other.session && @handle == other.handle
105
106
  end
106
107
  alias_method :==, :eql?
107
108
 
@@ -113,9 +114,9 @@ module Capybara
113
114
  "#<Window @handle=#{@handle.inspect}>"
114
115
  end
115
116
 
116
- private
117
+ private
117
118
 
118
- def wait_for_stable_size(seconds=session.config.default_max_wait_time)
119
+ def wait_for_stable_size(seconds = session.config.default_max_wait_time)
119
120
  res = yield if block_given?
120
121
  prev_size = size
121
122
  start_time = Capybara::Helpers.monotonic_time
@@ -125,16 +126,11 @@ module Capybara
125
126
  return res if cur_size == prev_size
126
127
  prev_size = cur_size
127
128
  end while (Capybara::Helpers.monotonic_time - start_time) < seconds
128
- #TODO raise error in 3.0
129
- #raise Capybara::WindowError, "Window size not stable."
130
- warn "Window size not stable in #{seconds} seconds. This will raise an exception in a future version of Capybara"
131
- return res
129
+ raise Capybara::WindowError, "Window size not stable within #{seconds} seconds."
132
130
  end
133
131
 
134
132
  def raise_unless_current(what)
135
- unless current?
136
- raise Capybara::WindowError, "#{what} not current window is not possible."
137
- end
133
+ raise Capybara::WindowError, "#{what} not current window is not possible." unless current?
138
134
  end
139
135
  end
140
136
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Capybara do
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'spec_helper'
3
4
 
4
5
  RSpec.describe Capybara do
@@ -12,15 +13,6 @@ RSpec.describe Capybara do
12
13
  Capybara.default_max_wait_time = 5
13
14
  expect(Capybara.default_max_wait_time).to eq(5)
14
15
  end
15
-
16
- it "should be accesible as the deprecated default_wait_time" do
17
- expect(Capybara.send(:config)).to receive(:warn).ordered.with('DEPRECATED: #default_wait_time= is deprecated, please use #default_max_wait_time= instead')
18
- expect(Capybara.send(:config)).to receive(:warn).ordered.with('DEPRECATED: #default_wait_time is deprecated, please use #default_max_wait_time instead')
19
- @previous_default_time = Capybara.default_max_wait_time
20
- Capybara.default_wait_time = 5
21
- expect(Capybara.default_wait_time).to eq(5)
22
- expect(Capybara.default_max_wait_time).to eq(5)
23
- end
24
16
  end
25
17
 
26
18
  describe '.register_driver' do
@@ -37,7 +29,7 @@ RSpec.describe Capybara do
37
29
  describe '.register_server' do
38
30
  it "should add a new server" do
39
31
  handler = double("handler")
40
- Capybara.register_server :blob do |app, port, host|
32
+ Capybara.register_server :blob do |_app, _port, _host|
41
33
  handler.run
42
34
  end
43
35
 
@@ -46,12 +38,8 @@ RSpec.describe Capybara do
46
38
  end
47
39
 
48
40
  describe ".server" do
49
- before do
50
- @old_server = Capybara.server
51
- end
52
-
53
41
  after do
54
- Capybara.server(&@old_server)
42
+ Capybara.server = :default
55
43
  end
56
44
 
57
45
  it "should default to a proc that calls run_default_server" do
@@ -61,8 +49,9 @@ RSpec.describe Capybara do
61
49
  end
62
50
 
63
51
  it "should return a custom server proc" do
64
- server = lambda {|app, port|}
65
- Capybara.server(&server)
52
+ server = ->(_app, _port) {}
53
+ Capybara.register_server :custom, &server
54
+ Capybara.server = :custom
66
55
  expect(Capybara.server).to eq(server)
67
56
  end
68
57
 
@@ -116,7 +105,7 @@ RSpec.describe Capybara do
116
105
  Capybara.default_host = old_default
117
106
  end
118
107
 
119
- it "should warn if not a valid URL" do
108
+ it "should raise if not a valid URL" do
120
109
  expect { Capybara.default_host = "www.example.com" }.to raise_error(ArgumentError, /Capybara\.default_host should be set to a url/)
121
110
  end
122
111
 
@@ -124,26 +113,14 @@ RSpec.describe Capybara do
124
113
  expect { Capybara.default_host = "http://www.example.com" }.not_to raise_error
125
114
  end
126
115
  end
127
-
128
- describe "configure" do
129
- it 'deprecates calling non configuration option methods in configure' do
130
- expect_any_instance_of(Kernel).to receive(:warn).
131
- with('Calling register_driver from Capybara.configure is deprecated - please call it on Capybara directly ( Capybara.register_driver(...) )')
132
- Capybara.configure do |config|
133
- config.register_driver(:random_name) do
134
- #just a random block
135
- end
136
- end
137
- end
138
- end
139
116
  end
140
117
 
141
118
  RSpec.describe Capybara::Session do
142
119
  context 'with nonexistent driver' do
143
120
  it "should raise an error" do
144
- expect {
121
+ expect do
145
122
  Capybara::Session.new(:quox, TestApp).driver
146
- }.to raise_error(Capybara::DriverNotFoundError)
123
+ end.to raise_error(Capybara::DriverNotFoundError)
147
124
  end
148
125
  end
149
126
  end