capybara 3.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +10 -0
  3. data/lib/capybara.rb +1 -1
  4. data/lib/capybara/helpers.rb +1 -1
  5. data/lib/capybara/minitest/spec.rb +2 -0
  6. data/lib/capybara/node/actions.rb +45 -5
  7. data/lib/capybara/queries/match_query.rb +2 -0
  8. data/lib/capybara/queries/selector_query.rb +3 -4
  9. data/lib/capybara/queries/text_query.rb +4 -5
  10. data/lib/capybara/rack_test/node.rb +6 -4
  11. data/lib/capybara/result.rb +1 -1
  12. data/lib/capybara/rspec/compound.rb +2 -0
  13. data/lib/capybara/selector.rb +72 -18
  14. data/lib/capybara/selector/css.rb +2 -0
  15. data/lib/capybara/selenium/driver.rb +14 -15
  16. data/lib/capybara/selenium/node.rb +23 -29
  17. data/lib/capybara/server.rb +29 -4
  18. data/lib/capybara/session.rb +12 -13
  19. data/lib/capybara/spec/session/all_spec.rb +6 -6
  20. data/lib/capybara/spec/session/{assert_current_path.rb → assert_current_path_spec.rb} +2 -3
  21. data/lib/capybara/spec/session/{assert_selector.rb → assert_selector_spec.rb} +0 -0
  22. data/lib/capybara/spec/session/{assert_text.rb → assert_text_spec.rb} +1 -1
  23. data/lib/capybara/spec/session/{assert_title.rb → assert_title_spec.rb} +0 -0
  24. data/lib/capybara/spec/session/check_spec.rb +6 -6
  25. data/lib/capybara/spec/session/click_link_or_button_spec.rb +0 -7
  26. data/lib/capybara/spec/session/current_url_spec.rb +6 -8
  27. data/lib/capybara/spec/session/element/{assert_match_selector.rb → assert_match_selector_spec.rb} +2 -0
  28. data/lib/capybara/spec/session/element/match_css_spec.rb +2 -0
  29. data/lib/capybara/spec/session/element/match_xpath_spec.rb +2 -0
  30. data/lib/capybara/spec/session/element/matches_selector_spec.rb +2 -0
  31. data/lib/capybara/spec/session/find_by_id_spec.rb +1 -1
  32. data/lib/capybara/spec/session/find_field_spec.rb +1 -1
  33. data/lib/capybara/spec/session/first_spec.rb +12 -12
  34. data/lib/capybara/spec/session/frame/frame_title_spec.rb +1 -1
  35. data/lib/capybara/spec/session/frame/frame_url_spec.rb +1 -1
  36. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +2 -2
  37. data/lib/capybara/spec/session/frame/within_frame_spec.rb +1 -1
  38. data/lib/capybara/spec/session/has_button_spec.rb +5 -0
  39. data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
  40. data/lib/capybara/spec/session/has_field_spec.rb +1 -1
  41. data/lib/capybara/spec/session/has_none_selectors_spec.rb +2 -0
  42. data/lib/capybara/spec/session/has_selector_spec.rb +8 -0
  43. data/lib/capybara/spec/session/{headers.rb → headers_spec.rb} +0 -0
  44. data/lib/capybara/spec/session/node_spec.rb +4 -4
  45. data/lib/capybara/spec/session/reset_session_spec.rb +2 -2
  46. data/lib/capybara/spec/session/{response_code.rb → response_code_spec.rb} +0 -0
  47. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +2 -1
  48. data/lib/capybara/spec/session/select_spec.rb +27 -1
  49. data/lib/capybara/spec/session/selectors_spec.rb +2 -0
  50. data/lib/capybara/spec/session/uncheck_spec.rb +3 -3
  51. data/lib/capybara/spec/session/visit_spec.rb +17 -10
  52. data/lib/capybara/spec/session/window/become_closed_spec.rb +3 -3
  53. data/lib/capybara/spec/session/window/current_window_spec.rb +2 -2
  54. data/lib/capybara/spec/session/window/open_new_window_spec.rb +3 -3
  55. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +5 -5
  56. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +3 -3
  57. data/lib/capybara/spec/session/window/window_spec.rb +24 -9
  58. data/lib/capybara/spec/session/window/windows_spec.rb +2 -2
  59. data/lib/capybara/spec/session/window/within_window_spec.rb +2 -2
  60. data/lib/capybara/spec/session/within_spec.rb +3 -3
  61. data/lib/capybara/spec/spec_helper.rb +7 -5
  62. data/lib/capybara/spec/views/form.erb +9 -0
  63. data/lib/capybara/version.rb +1 -1
  64. data/spec/basic_node_spec.rb +1 -1
  65. data/spec/capybara_spec.rb +4 -14
  66. data/spec/dsl_spec.rb +5 -3
  67. data/spec/fixtures/certificate.pem +25 -0
  68. data/spec/fixtures/key.pem +27 -0
  69. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  70. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  71. data/spec/rack_test_spec.rb +8 -6
  72. data/spec/result_spec.rb +22 -2
  73. data/spec/rspec/features_spec.rb +4 -2
  74. data/spec/rspec/scenarios_spec.rb +1 -1
  75. data/spec/rspec/shared_spec_matchers.rb +7 -4
  76. data/spec/rspec/views_spec.rb +2 -1
  77. data/spec/rspec_spec.rb +80 -78
  78. data/spec/selenium_spec_marionette.rb +6 -4
  79. data/spec/server_spec.rb +40 -2
  80. data/spec/session_spec.rb +12 -4
  81. data/spec/shared_selenium_session.rb +106 -84
  82. metadata +11 -9
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Capybara::SpecHelper.spec '#windows', requires: [:windows] do
4
- before(:each) do
4
+ before do
5
5
  @window = @session.current_window
6
6
  @session.visit('/with_windows')
7
7
  @session.find(:css, '#openTwoWindows').click
@@ -10,7 +10,7 @@ Capybara::SpecHelper.spec '#windows', requires: [:windows] do
10
10
  raise Capybara::CapybaraError if @session.windows.size != 3
11
11
  end
12
12
  end
13
- after(:each) do
13
+ after do
14
14
  (@session.windows - [@window]).each do |w|
15
15
  @session.switch_to_window w
16
16
  w.close
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
4
- before(:each) do
4
+ before do
5
5
  @window = @session.current_window
6
6
  @session.visit('/with_windows')
7
7
  @session.find(:css, '#openTwoWindows').click
@@ -10,7 +10,7 @@ Capybara::SpecHelper.spec '#within_window', requires: [:windows] do
10
10
  raise Capybara::CapybaraError if @session.windows.size != 3
11
11
  end
12
12
  end
13
- after(:each) do
13
+ after do
14
14
  (@session.windows - [@window]).each do |w|
15
15
  @session.switch_to_window w
16
16
  w.close
@@ -7,7 +7,7 @@ Capybara::SpecHelper.spec '#within' do
7
7
 
8
8
  context "with CSS selector" do
9
9
  it "should click links in the given scope" do
10
- @session.within(:css, "#for_bar li", text: 'With Simple HTML') do
10
+ @session.within(:css, "#for_bar li:first-child") do
11
11
  @session.click_link('Go')
12
12
  end
13
13
  expect(@session).to have_content('Bar')
@@ -103,9 +103,9 @@ Capybara::SpecHelper.spec '#within' do
103
103
  @session.within(".//div[@id='doesnotexist']") do
104
104
  end
105
105
  end.to raise_error(Capybara::ElementNotFound)
106
- end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
106
+ end.not_to change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
107
107
  end
108
- end.to_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
108
+ end.not_to change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
109
109
  end
110
110
 
111
111
  it "should fill in a field and click a button" do
@@ -49,31 +49,33 @@ module Capybara
49
49
 
50
50
  def run_specs(session, name, **options)
51
51
  specs = @specs
52
- RSpec.describe Capybara::Session, name, options do
52
+ RSpec.describe Capybara::Session, name, options do # rubocop:disable RSpec/EmptyExampleGroup
53
53
  include Capybara::SpecHelper
54
54
  include Capybara::RSpecMatchers
55
+ # rubocop:disable RSpec/ScatteredSetup
55
56
  before do
56
57
  @session = session
57
58
  end
58
59
 
59
60
  after do
60
- @session.reset_session!
61
+ session.reset_session!
61
62
  end
62
63
 
63
64
  before :each, psc: true do
64
- SpecHelper.reset_threadsafe(true, @session)
65
+ SpecHelper.reset_threadsafe(true, session)
65
66
  end
66
67
 
67
68
  after psc: true do
68
- SpecHelper.reset_threadsafe(false, @session)
69
+ SpecHelper.reset_threadsafe(false, session)
69
70
  end
70
71
 
71
72
  before :each, :exact_false do
72
73
  Capybara.exact = false
73
74
  end
75
+ # rubocop:enable RSpec/ScatteredSetup
74
76
 
75
77
  specs.each do |spec_name, spec_options, block|
76
- describe spec_name, *spec_options do
78
+ describe spec_name, *spec_options do # rubocop:disable RSpec/EmptyExampleGroup
77
79
  class_eval(&block)
78
80
  end
79
81
  end
@@ -197,6 +197,15 @@ New line after and before textarea tag
197
197
  </label>
198
198
  </p>
199
199
 
200
+ <p>
201
+ <input type="text" name="form[manufacturer]" list="manufacturers" id="manufacturer"/>
202
+ <datalist id="manufacturers">
203
+ <option value="Jaguar">J</option>
204
+ <option value="Audi">
205
+ <option value="Mercedes" disabled>
206
+ </datalist>
207
+ </p>
208
+
200
209
  <p>
201
210
  <input type="checkbox" name="form[valueless_checkbox]" id="valueless_checkbox" checked="checked"/>
202
211
  <label for="valueless_checkbox">Valueless Checkbox</label>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Capybara
4
- VERSION = '3.0.3'.freeze
4
+ VERSION = '3.1.0'.freeze
5
5
  end
@@ -95,7 +95,7 @@ RSpec.describe Capybara do
95
95
  expect(string.find('//h1').path).to eq('/html/body/div/div[1]/h1')
96
96
  end
97
97
 
98
- it "allows finding elements and extracting the path" do
98
+ it "allows finding elements and extracting the value" do
99
99
  expect(string.find('//div/input').value).to eq('bar')
100
100
  expect(string.find('//select').value).to eq('Capybara')
101
101
  end
@@ -28,9 +28,8 @@ RSpec.describe Capybara do
28
28
 
29
29
  describe '.register_server' do
30
30
  it "should add a new server" do
31
- handler = double("handler")
32
31
  Capybara.register_server :blob do |_app, _port, _host|
33
- handler.run
32
+ # do nothing
34
33
  end
35
34
 
36
35
  expect(Capybara.servers).to have_key(:blob)
@@ -43,9 +42,10 @@ RSpec.describe Capybara do
43
42
  end
44
43
 
45
44
  it "should default to a proc that calls run_default_server" do
46
- mock_app = double('app')
47
- expect(Capybara).to receive(:run_default_server).with(mock_app, 8000)
45
+ mock_app = Object.new
46
+ allow(Capybara).to receive(:run_default_server).and_return(true)
48
47
  Capybara.server.call(mock_app, 8000)
48
+ expect(Capybara).to have_received(:run_default_server).with(mock_app, 8000)
49
49
  end
50
50
 
51
51
  it "should return a custom server proc" do
@@ -110,13 +110,3 @@ RSpec.describe Capybara do
110
110
  end
111
111
  end
112
112
  end
113
-
114
- RSpec.describe Capybara::Session do
115
- context 'with nonexistent driver' do
116
- it "should raise an error" do
117
- expect do
118
- Capybara::Session.new(:quox, TestApp).driver
119
- end.to raise_error(Capybara::DriverNotFoundError)
120
- end
121
- end
122
- end
@@ -65,7 +65,7 @@ RSpec.describe Capybara::DSL do
65
65
 
66
66
  describe '#using_driver' do
67
67
  before do
68
- expect(Capybara.current_driver).not_to eq(:selenium)
68
+ expect(Capybara.current_driver).not_to eq(:selenium) # rubocop:disable RSpec/ExpectInHook
69
69
  end
70
70
 
71
71
  it 'should set the driver using Capybara.current_driver=' do
@@ -250,13 +250,15 @@ RSpec.describe Capybara::DSL do
250
250
  end
251
251
 
252
252
  it "should provide an 'using_session' shortcut" do
253
- expect(Capybara).to receive(:using_session).with(:name)
253
+ allow(Capybara).to receive(:using_session)
254
254
  @session.using_session(:name)
255
+ expect(Capybara).to have_received(:using_session).with(:name)
255
256
  end
256
257
 
257
258
  it "should provide a 'using_wait_time' shortcut" do
258
- expect(Capybara).to receive(:using_wait_time).with(6)
259
+ allow(Capybara).to receive(:using_wait_time)
259
260
  @session.using_wait_time(6)
261
+ expect(Capybara).to have_received(:using_wait_time).with(6)
260
262
  end
261
263
  end
262
264
  end
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEITCCAwmgAwIBAgIJALROkwd1gZHQMA0GCSqGSIb3DQEBBQUAMGgxCzAJBgNV
3
+ BAYTAlVTMQswCQYDVQQIEwJDQTERMA8GA1UEChMIQ2FweWJhcmExFjAUBgNVBAMT
4
+ DWNhcHliYXJhLnRlc3QxITAfBgkqhkiG9w0BCQEWEnR3YWxwb2xlQGdtYWlsLmNv
5
+ bTAeFw0xODA1MDEyMDI5NDVaFw0yODA0MjgyMDI5NDVaMGgxCzAJBgN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+ by38VAbFRVIMrzdfbvwSFrE3Nd9BvyLWl16G+MVu+hq0jhM9p44a62vXvfgQmfFh
15
+ iXyGkzCTufeLEzOFnP8S+ezacodK1hbQTjllUndn6NUhXcbfozTPfx8CgYEAw1Il
16
+ xqfU7NkVX6UP/FvTx9aBKqwrD8YOPn9nj26Q45zVbmHJZZIvywlsMDCiJ6JJawEa
17
+ GSkiZTDpypEvS/2UtLEY0zfbSbQGkBTnagHIFAuVh0AD1EP+kCcnrxA5Vjr8v0WE
18
+ B0HBfMgoZxa8rmHMpPhrlCCo1ectRgu+dgzEKhsCgYAQ17lwBpc69tSHUSVClCAD
19
+ AkABWAT5QKARsO91xOs8AOgznTjk6hmrinD+RyZosEliUlv+YMHm/S82VT1b3MCN
20
+ mDOF8+SwubOGDQ2NhieRycTQaS7U7kcetl9o8VBAqMWYGVPZaeKhKKzcIPeMyiRj
21
+ 38FOd/Nq3U5NveG4XwnJCQKBgGrzmnfTAsbGf+uliMFYzviIPqZNLC8w9i/Gt8BU
22
+ fMYF5ODSbuNNTxpQiItCtigZtzX+nnnUil76j6o6IbnsmvbuWneeCFetWkKfD7B+
23
+ VT6UsUYkCXS73rK0nghATAUpu6hIumj22qonN+hrDNo390UGOnIcCBdIxQOr/pjJ
24
+ mMitAoGAB3tFzlzZHpCE38IqdHL7CKIML9cYJSOm07nFIEUAKN2bUHGsvMH/tMS1
25
+ I3hyeHxMmYCrOLn7xLqiOVgRjbYS9JiQVdDojqeSvvnLCtY9/lHWi50pqbPfwyfK
26
+ Og6QoFyxjBEsoSilc6dai58VTO6ufhoJXbXX9PcIl7le4dVPnzE=
27
+ -----END RSA PRIVATE KEY-----
@@ -7,7 +7,7 @@ RSpec.describe Capybara::Selenium::Driver do
7
7
  it "should exit with a non-zero exit status" do
8
8
  options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
9
9
  browser = Capybara::Selenium::Driver.new(TestApp, options).browser
10
- expect(browser).to be
11
- expect(true).to eq(false)
10
+ expect(browser).to be_truthy
11
+ expect(true).to eq(false) # rubocop:disable RSpec/ExpectActual
12
12
  end
13
13
  end
@@ -7,7 +7,7 @@ RSpec.describe Capybara::Selenium::Driver do
7
7
  it "should exit with a zero exit status" do
8
8
  options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
9
9
  browser = Capybara::Selenium::Driver.new(TestApp, options).browser
10
- expect(browser).to be
11
- expect(true).to eq(true)
10
+ expect(browser).to be_truthy
11
+ expect(true).to eq(true) # rubocop:disable RSpec/ExpectActual
12
12
  end
13
13
  end
@@ -6,7 +6,7 @@ module TestSessions
6
6
  RackTest = Capybara::Session.new(:rack_test, TestApp)
7
7
  end
8
8
 
9
- Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", capybara_skip: %i[
9
+ skipped_tests = %i[
10
10
  js
11
11
  modals
12
12
  screenshot
@@ -17,8 +17,9 @@ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", capybara_skip
17
17
  hover
18
18
  about_scheme
19
19
  ]
20
+ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", capybara_skip: skipped_tests
20
21
 
21
- RSpec.describe Capybara::Session do
22
+ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
22
23
  context 'with rack test driver' do
23
24
  before do
24
25
  @session = TestSessions::RackTest
@@ -65,11 +66,11 @@ RSpec.describe Capybara::Session do
65
66
 
66
67
  describe "#fill_in" do
67
68
  it "should warn that :fill_options are not supported" do
68
- expect_any_instance_of(Capybara::RackTest::Node).to receive(:warn)
69
- .with("Options passed to Node#set but the RackTest driver doesn't support any - ignoring")
69
+ allow_any_instance_of(Capybara::RackTest::Node).to receive(:warn)
70
70
  @session.visit "/with_html"
71
- @session.fill_in 'test_field', with: 'not_monkey', fill_options: { random: true }
71
+ field = @session.fill_in 'test_field', with: 'not_monkey', fill_options: { random: true }
72
72
  expect(@session).to have_field('test_field', with: 'not_monkey')
73
+ expect(field.base).to have_received(:warn).with("Options passed to Node#set but the RackTest driver doesn't support any - ignoring")
73
74
  end
74
75
  end
75
76
 
@@ -220,9 +221,10 @@ module CSSHandlerIncludeTester
220
221
  raise 'should never be called'
221
222
  end
222
223
  end
223
- include CSSHandlerIncludeTester # rubocop:disable Style/MixinUsage
224
224
 
225
225
  RSpec.describe Capybara::RackTest::CSSHandlers do
226
+ include CSSHandlerIncludeTester
227
+
226
228
  it "should not be extended by global includes" do
227
229
  expect(Capybara::RackTest::CSSHandlers.new).not_to respond_to(:dont_extend_css_handler)
228
230
  end
@@ -79,14 +79,18 @@ RSpec.describe Capybara::Result do
79
79
 
80
80
  it 'should catch invalid element errors during filtering' do
81
81
  allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
82
- allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(double("session", driver: double("driver", invalid_element_errors: [StandardError])))
82
+ allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
83
+ instance_double("Capybara::Session", driver: instance_double("Capybara::Driver::Base", invalid_element_errors: [StandardError]))
84
+ )
83
85
  result = string.all('//li', text: 'Alpha')
84
86
  expect(result.size).to eq 0
85
87
  end
86
88
 
87
89
  it 'should return non-invalid element errors during filtering' do
88
90
  allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
89
- allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(double("session", driver: double("driver", invalid_element_errors: [ArgumentError])))
91
+ allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
92
+ instance_double("Capybara::Session", driver: instance_double("Capybara::Driver::Base", invalid_element_errors: [ArgumentError]))
93
+ )
90
94
  expect do
91
95
  string.all('//li', text: 'Alpha').to_a
92
96
  end.to raise_error(StandardError)
@@ -139,4 +143,20 @@ RSpec.describe Capybara::Result do
139
143
  end
140
144
  end
141
145
  end
146
+
147
+ context 'lazy select' do
148
+ it 'is compatible' do
149
+ # This test will let us know when JRuby fixes lazy select so we can re-enable it in Result
150
+ pending 'JRuby has an issue with lazy enumberator evaluation' if RUBY_PLATFORM == 'java'
151
+ eval_count = 0
152
+ enum = %w[Text1 Text2 Text3].lazy.select do
153
+ eval_count += 1
154
+ true
155
+ end
156
+ expect(eval_count).to eq 0
157
+ enum.next
158
+ sleep 1
159
+ expect(eval_count).to eq 1
160
+ end
161
+ end
142
162
  end
@@ -39,7 +39,7 @@ feature "Capybara's feature DSL" do
39
39
  end
40
40
 
41
41
  scenario "doesn't pollute the Object namespace" do
42
- expect(Object.new.respond_to?(:feature, true)).to be_falsey
42
+ expect(Object.new).not_to respond_to(:feature)
43
43
  end
44
44
 
45
45
  feature 'nested features' do
@@ -78,6 +78,7 @@ feature "Capybara's feature DSL with driver", driver: :culerity do
78
78
  end
79
79
  end
80
80
 
81
+ # rubocop:disable RSpec/RepeatedExample
81
82
  xfeature "if xfeature aliases to pending then" do
82
83
  scenario "this should be 'temporarily disabled with xfeature'" do
83
84
  # dummy
@@ -87,7 +88,7 @@ xfeature "if xfeature aliases to pending then" do
87
88
  end
88
89
  end
89
90
 
90
- ffeature "if ffeature aliases focused tag then" do
91
+ ffeature "if ffeature aliases focused tag then" do # rubocop:disable RSpec/Focus
91
92
  scenario "scenario inside this feature has metatag focus tag" do |example|
92
93
  expect(example.metadata[:focus]).to eq true
93
94
  end
@@ -96,3 +97,4 @@ ffeature "if ffeature aliases focused tag then" do
96
97
  expect(example.metadata[:focus]).to eq true
97
98
  end
98
99
  end
100
+ # rubocop:enable RSpec/RepeatedExample
@@ -8,7 +8,7 @@ RSpec.configuration.before(:each, file_path: "./spec/rspec/scenarios_spec.rb") d
8
8
  end
9
9
 
10
10
  feature "if fscenario aliases focused tag then" do
11
- fscenario "scenario should have focused meta tag" do |example|
11
+ fscenario "scenario should have focused meta tag" do |example| # rubocop:disable RSpec/Focus
12
12
  expect(example.metadata[:focus]).to eq true
13
13
  end
14
14
  end
@@ -5,6 +5,8 @@ require 'capybara/dsl'
5
5
  require 'capybara/rspec/matchers'
6
6
  require 'benchmark'
7
7
 
8
+ # rubocop:disable RSpec/ExpectActual
9
+
8
10
  RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
9
11
  include Capybara::DSL
10
12
  include Capybara::RSpecMatchers
@@ -548,7 +550,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
548
550
  end
549
551
 
550
552
  context 'with wait' do
551
- before(:each) do
553
+ before do
552
554
  @session = session
553
555
  @session.visit('/with_js')
554
556
  end
@@ -593,7 +595,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
593
595
  end
594
596
 
595
597
  context 'with wait' do
596
- before(:each) do
598
+ before do
597
599
  @session = session
598
600
  @session.visit('/with_js')
599
601
  end
@@ -840,8 +842,8 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
840
842
  end
841
843
  end
842
844
 
843
- context "compounding", requires: [:js] do
844
- before(:each) do
845
+ context "compounding timing" do
846
+ before do
845
847
  @session = session
846
848
  @session.visit('/with_js')
847
849
  @el = @session.find(:css, '#reload-me')
@@ -934,3 +936,4 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
934
936
  end
935
937
  end
936
938
  end
939
+ # rubocop:enable RSpec/ExpectActual
@@ -4,7 +4,8 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe "capybara/rspec", type: :view do
6
6
  it "allows matchers to be used on strings" do
7
- expect(%(<h1>Test header</h1>)).to have_css("h1", text: "Test header")
7
+ html = %(<h1>Test header</h1>)
8
+ expect(html).to have_css("h1", text: "Test header")
8
9
  end
9
10
 
10
11
  it "doesn't include RSpecMatcherProxies" do