capybara 3.3.1 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +16 -0
  3. data/README.md +5 -7
  4. data/lib/capybara.rb +7 -6
  5. data/lib/capybara/config.rb +1 -1
  6. data/lib/capybara/dsl.rb +2 -2
  7. data/lib/capybara/helpers.rb +3 -3
  8. data/lib/capybara/minitest/spec.rb +3 -3
  9. data/lib/capybara/node/actions.rb +18 -18
  10. data/lib/capybara/node/base.rb +1 -1
  11. data/lib/capybara/node/element.rb +2 -2
  12. data/lib/capybara/node/finders.rb +6 -6
  13. data/lib/capybara/node/matchers.rb +5 -5
  14. data/lib/capybara/node/simple.rb +2 -2
  15. data/lib/capybara/queries/ancestor_query.rb +1 -1
  16. data/lib/capybara/queries/base_query.rb +12 -11
  17. data/lib/capybara/queries/current_path_query.rb +1 -1
  18. data/lib/capybara/queries/selector_query.rb +39 -15
  19. data/lib/capybara/queries/sibling_query.rb +1 -1
  20. data/lib/capybara/queries/text_query.rb +1 -1
  21. data/lib/capybara/rack_test/browser.rb +7 -7
  22. data/lib/capybara/rack_test/driver.rb +1 -1
  23. data/lib/capybara/rack_test/form.rb +7 -7
  24. data/lib/capybara/rack_test/node.rb +16 -16
  25. data/lib/capybara/rails.rb +1 -1
  26. data/lib/capybara/result.rb +8 -4
  27. data/lib/capybara/rspec/features.rb +4 -4
  28. data/lib/capybara/rspec/matchers.rb +6 -6
  29. data/lib/capybara/selector.rb +106 -90
  30. data/lib/capybara/selector/css.rb +4 -4
  31. data/lib/capybara/selector/filter_set.rb +52 -8
  32. data/lib/capybara/selector/selector.rb +39 -15
  33. data/lib/capybara/selenium/driver.rb +10 -10
  34. data/lib/capybara/selenium/driver_specializations/chrome_driver.rb +8 -0
  35. data/lib/capybara/selenium/node.rb +9 -10
  36. data/lib/capybara/selenium/nodes/chrome_node.rb +18 -0
  37. data/lib/capybara/selenium/nodes/marionette_node.rb +32 -7
  38. data/lib/capybara/server.rb +3 -3
  39. data/lib/capybara/server/animation_disabler.rb +1 -1
  40. data/lib/capybara/server/middleware.rb +1 -1
  41. data/lib/capybara/session.rb +23 -19
  42. data/lib/capybara/session/config.rb +18 -3
  43. data/lib/capybara/spec/public/test.js +1 -1
  44. data/lib/capybara/spec/session/accept_alert_spec.rb +10 -10
  45. data/lib/capybara/spec/session/accept_confirm_spec.rb +3 -3
  46. data/lib/capybara/spec/session/accept_prompt_spec.rb +9 -10
  47. data/lib/capybara/spec/session/all_spec.rb +33 -32
  48. data/lib/capybara/spec/session/ancestor_spec.rb +19 -19
  49. data/lib/capybara/spec/session/assert_all_of_selectors_spec.rb +38 -38
  50. data/lib/capybara/spec/session/assert_current_path_spec.rb +16 -16
  51. data/lib/capybara/spec/session/assert_selector_spec.rb +53 -53
  52. data/lib/capybara/spec/session/assert_style_spec.rb +3 -3
  53. data/lib/capybara/spec/session/assert_text_spec.rb +31 -30
  54. data/lib/capybara/spec/session/assert_title_spec.rb +12 -12
  55. data/lib/capybara/spec/session/attach_file_spec.rb +51 -52
  56. data/lib/capybara/spec/session/body_spec.rb +6 -6
  57. data/lib/capybara/spec/session/check_spec.rb +52 -47
  58. data/lib/capybara/spec/session/choose_spec.rb +32 -32
  59. data/lib/capybara/spec/session/click_button_spec.rb +103 -103
  60. data/lib/capybara/spec/session/click_link_or_button_spec.rb +24 -23
  61. data/lib/capybara/spec/session/click_link_spec.rb +49 -48
  62. data/lib/capybara/spec/session/current_scope_spec.rb +7 -7
  63. data/lib/capybara/spec/session/current_url_spec.rb +26 -27
  64. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +3 -3
  65. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +2 -2
  66. data/lib/capybara/spec/session/element/assert_match_selector_spec.rb +8 -8
  67. data/lib/capybara/spec/session/element/match_css_spec.rb +10 -10
  68. data/lib/capybara/spec/session/element/match_xpath_spec.rb +6 -6
  69. data/lib/capybara/spec/session/element/matches_selector_spec.rb +51 -51
  70. data/lib/capybara/spec/session/evaluate_async_script_spec.rb +7 -7
  71. data/lib/capybara/spec/session/evaluate_script_spec.rb +15 -8
  72. data/lib/capybara/spec/session/execute_script_spec.rb +7 -7
  73. data/lib/capybara/spec/session/fill_in_spec.rb +43 -42
  74. data/lib/capybara/spec/session/find_button_spec.rb +23 -23
  75. data/lib/capybara/spec/session/find_by_id_spec.rb +7 -7
  76. data/lib/capybara/spec/session/find_field_spec.rb +32 -30
  77. data/lib/capybara/spec/session/find_link_spec.rb +21 -21
  78. data/lib/capybara/spec/session/find_spec.rb +153 -135
  79. data/lib/capybara/spec/session/first_spec.rb +41 -41
  80. data/lib/capybara/spec/session/frame/frame_title_spec.rb +5 -5
  81. data/lib/capybara/spec/session/frame/frame_url_spec.rb +5 -5
  82. data/lib/capybara/spec/session/frame/switch_to_frame_spec.rb +17 -17
  83. data/lib/capybara/spec/session/frame/within_frame_spec.rb +31 -17
  84. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  85. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  86. data/lib/capybara/spec/session/has_all_selectors_spec.rb +17 -17
  87. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  88. data/lib/capybara/spec/session/has_css_spec.rb +133 -131
  89. data/lib/capybara/spec/session/has_current_path_spec.rb +29 -29
  90. data/lib/capybara/spec/session/has_field_spec.rb +58 -58
  91. data/lib/capybara/spec/session/has_link_spec.rb +4 -4
  92. data/lib/capybara/spec/session/has_none_selectors_spec.rb +24 -24
  93. data/lib/capybara/spec/session/has_select_spec.rb +43 -43
  94. data/lib/capybara/spec/session/has_selector_spec.rb +71 -71
  95. data/lib/capybara/spec/session/has_style_spec.rb +3 -3
  96. data/lib/capybara/spec/session/has_table_spec.rb +4 -4
  97. data/lib/capybara/spec/session/has_text_spec.rb +53 -52
  98. data/lib/capybara/spec/session/has_title_spec.rb +14 -14
  99. data/lib/capybara/spec/session/has_xpath_spec.rb +39 -38
  100. data/lib/capybara/spec/session/headers_spec.rb +1 -1
  101. data/lib/capybara/spec/session/html_spec.rb +6 -6
  102. data/lib/capybara/spec/session/node_spec.rb +129 -123
  103. data/lib/capybara/spec/session/node_wrapper_spec.rb +10 -7
  104. data/lib/capybara/spec/session/refresh_spec.rb +4 -7
  105. data/lib/capybara/spec/session/reset_session_spec.rb +28 -28
  106. data/lib/capybara/spec/session/response_code_spec.rb +1 -1
  107. data/lib/capybara/spec/session/save_and_open_page_spec.rb +2 -2
  108. data/lib/capybara/spec/session/save_page_spec.rb +37 -37
  109. data/lib/capybara/spec/session/save_screenshot_spec.rb +6 -6
  110. data/lib/capybara/spec/session/screenshot_spec.rb +2 -2
  111. data/lib/capybara/spec/session/select_spec.rb +81 -81
  112. data/lib/capybara/spec/session/selectors_spec.rb +17 -17
  113. data/lib/capybara/spec/session/sibling_spec.rb +9 -9
  114. data/lib/capybara/spec/session/text_spec.rb +23 -23
  115. data/lib/capybara/spec/session/title_spec.rb +5 -5
  116. data/lib/capybara/spec/session/uncheck_spec.rb +24 -20
  117. data/lib/capybara/spec/session/unselect_spec.rb +37 -37
  118. data/lib/capybara/spec/session/visit_spec.rb +48 -49
  119. data/lib/capybara/spec/session/window/current_window_spec.rb +1 -1
  120. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +16 -16
  121. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +2 -2
  122. data/lib/capybara/spec/session/window/window_spec.rb +4 -4
  123. data/lib/capybara/spec/session/window/within_window_spec.rb +14 -14
  124. data/lib/capybara/spec/session/within_spec.rb +41 -41
  125. data/lib/capybara/spec/spec_helper.rb +11 -9
  126. data/lib/capybara/spec/test_app.rb +18 -17
  127. data/lib/capybara/spec/views/form.erb +29 -31
  128. data/lib/capybara/spec/views/with_html.erb +2 -2
  129. data/lib/capybara/version.rb +1 -1
  130. data/spec/basic_node_spec.rb +23 -23
  131. data/spec/capybara_spec.rb +20 -20
  132. data/spec/css_splitter_spec.rb +7 -7
  133. data/spec/dsl_spec.rb +37 -32
  134. data/spec/filter_set_spec.rb +4 -4
  135. data/spec/fixtures/selenium_driver_rspec_failure.rb +1 -1
  136. data/spec/fixtures/selenium_driver_rspec_success.rb +1 -1
  137. data/spec/minitest_spec.rb +4 -4
  138. data/spec/minitest_spec_spec.rb +23 -23
  139. data/spec/per_session_config_spec.rb +5 -5
  140. data/spec/rack_test_spec.rb +44 -44
  141. data/spec/result_spec.rb +14 -14
  142. data/spec/rspec/features_spec.rb +13 -13
  143. data/spec/rspec/scenarios_spec.rb +4 -4
  144. data/spec/rspec/shared_spec_matchers.rb +282 -281
  145. data/spec/rspec/views_spec.rb +3 -3
  146. data/spec/rspec_matchers_spec.rb +10 -10
  147. data/spec/rspec_spec.rb +29 -29
  148. data/spec/selector_spec.rb +64 -64
  149. data/spec/selenium_spec_chrome.rb +14 -22
  150. data/spec/selenium_spec_chrome_remote.rb +28 -8
  151. data/spec/selenium_spec_edge.rb +9 -4
  152. data/spec/selenium_spec_firefox_remote.rb +87 -0
  153. data/spec/selenium_spec_ie.rb +9 -4
  154. data/spec/selenium_spec_marionette.rb +42 -18
  155. data/spec/server_spec.rb +29 -27
  156. data/spec/session_spec.rb +17 -17
  157. data/spec/shared_selenium_session.rb +70 -52
  158. data/spec/spec_helper.rb +1 -1
  159. metadata +4 -2
@@ -19,7 +19,7 @@ skipped_tests = %i[
19
19
  download
20
20
  css
21
21
  ]
22
- Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", capybara_skip: skipped_tests
22
+ Capybara::SpecHelper.run_specs TestSessions::RackTest, 'RackTest', capybara_skip: skipped_tests
23
23
 
24
24
  RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
25
25
  context 'with rack test driver' do
@@ -28,36 +28,36 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
28
28
  end
29
29
 
30
30
  describe '#driver' do
31
- it "should be a rack test driver" do
31
+ it 'should be a rack test driver' do
32
32
  expect(@session.driver).to be_an_instance_of(Capybara::RackTest::Driver)
33
33
  end
34
34
  end
35
35
 
36
36
  describe '#mode' do
37
- it "should remember the mode" do
37
+ it 'should remember the mode' do
38
38
  expect(@session.mode).to eq(:rack_test)
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#click_link' do
43
- it "should use data-method if option is true" do
43
+ it 'should use data-method if option is true' do
44
44
  @session.driver.options[:respect_data_method] = true
45
- @session.visit "/with_html"
46
- @session.click_link "A link with data-method"
45
+ @session.visit '/with_html'
46
+ @session.click_link 'A link with data-method'
47
47
  expect(@session.html).to include('The requested object was deleted')
48
48
  end
49
49
 
50
- it "should not use data-method if option is false" do
50
+ it 'should not use data-method if option is false' do
51
51
  @session.driver.options[:respect_data_method] = false
52
- @session.visit "/with_html"
53
- @session.click_link "A link with data-method"
52
+ @session.visit '/with_html'
53
+ @session.click_link 'A link with data-method'
54
54
  expect(@session.html).to include('Not deleted')
55
55
  end
56
56
 
57
57
  it "should use data-method if available even if it's capitalized" do
58
58
  @session.driver.options[:respect_data_method] = true
59
- @session.visit "/with_html"
60
- @session.click_link "A link with capitalized data-method"
59
+ @session.visit '/with_html'
60
+ @session.click_link 'A link with capitalized data-method'
61
61
  expect(@session.html).to include('The requested object was deleted')
62
62
  end
63
63
 
@@ -66,38 +66,38 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
66
66
  end
67
67
  end
68
68
 
69
- describe "#fill_in" do
70
- it "should warn that :fill_options are not supported" do
69
+ describe '#fill_in' do
70
+ it 'should warn that :fill_options are not supported' do
71
71
  allow_any_instance_of(Capybara::RackTest::Node).to receive(:warn)
72
- @session.visit "/with_html"
72
+ @session.visit '/with_html'
73
73
  field = @session.fill_in 'test_field', with: 'not_monkey', fill_options: { random: true }
74
74
  expect(@session).to have_field('test_field', with: 'not_monkey')
75
75
  expect(field.base).to have_received(:warn).with("Options passed to Node#set but the RackTest driver doesn't support any - ignoring")
76
76
  end
77
77
  end
78
78
 
79
- describe "#attach_file" do
80
- context "with multipart form" do
81
- it "should submit an empty form-data section if no file is submitted" do
82
- @session.visit("/form")
83
- @session.click_button("Upload Empty")
79
+ describe '#attach_file' do
80
+ context 'with multipart form' do
81
+ it 'should submit an empty form-data section if no file is submitted' do
82
+ @session.visit('/form')
83
+ @session.click_button('Upload Empty')
84
84
  expect(@session.html).to include('Successfully ignored empty file field.')
85
85
  end
86
86
  end
87
87
 
88
- it "should not submit an obsolete mime type" do
88
+ it 'should not submit an obsolete mime type' do
89
89
  @test_jpg_file_path = File.expand_path('fixtures/capybara.csv', File.dirname(__FILE__))
90
- @session.visit("/form")
91
- @session.attach_file "form_document", @test_jpg_file_path
90
+ @session.visit('/form')
91
+ @session.attach_file 'form_document', @test_jpg_file_path
92
92
  @session.click_button('Upload Single')
93
- expect(@session).to have_content("Content-type: text/csv")
93
+ expect(@session).to have_content('Content-type: text/csv')
94
94
  end
95
95
  end
96
96
 
97
- describe "#click" do
98
- context "on a label" do
99
- it "should toggle the associated checkbox" do
100
- @session.visit("/form")
97
+ describe '#click' do
98
+ context 'on a label' do
99
+ it 'should toggle the associated checkbox' do
100
+ @session.visit('/form')
101
101
  expect(@session).to have_unchecked_field('form_pets_cat')
102
102
  @session.find(:label, 'Cat').click
103
103
  expect(@session).to have_checked_field('form_pets_cat')
@@ -107,8 +107,8 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
107
107
  expect(@session).to have_checked_field('form_cars_mclaren', visible: :hidden)
108
108
  end
109
109
 
110
- it "should toggle the associated radio" do
111
- @session.visit("/form")
110
+ it 'should toggle the associated radio' do
111
+ @session.visit('/form')
112
112
  expect(@session).to have_unchecked_field('gender_male')
113
113
  @session.find(:label, 'Male').click
114
114
  expect(@session).to have_checked_field('gender_male')
@@ -119,7 +119,7 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
119
119
  end
120
120
 
121
121
  describe '#text' do
122
- it "should return original text content for textareas" do
122
+ it 'should return original text content for textareas' do
123
123
  @session.visit('/with_html')
124
124
  @session.find_field('normal', type: 'textarea', with: 'banana').set('hello')
125
125
  normal = @session.find(:css, '#normal')
@@ -129,7 +129,7 @@ RSpec.describe Capybara::Session do # rubocop:disable RSpec/MultipleDescribes
129
129
  end
130
130
 
131
131
  describe '#style' do
132
- it "should raise an error" do
132
+ it 'should raise an error' do
133
133
  @session.visit('/with_html')
134
134
  el = @session.find(:css, '#first')
135
135
  expect { el.style('display') }.to raise_error NotImplementedError, /not process CSS/
@@ -172,7 +172,7 @@ RSpec.describe Capybara::RackTest::Driver do
172
172
  end
173
173
 
174
174
  describe ':follow_redirects option' do
175
- it "defaults to following redirects" do
175
+ it 'defaults to following redirects' do
176
176
  @driver = Capybara::RackTest::Driver.new(TestApp)
177
177
 
178
178
  @driver.visit('/redirect')
@@ -180,7 +180,7 @@ RSpec.describe Capybara::RackTest::Driver do
180
180
  expect(@driver.current_url).to match %r{/landed$}
181
181
  end
182
182
 
183
- it "is possible to not follow redirects" do
183
+ it 'is possible to not follow redirects' do
184
184
  @driver = Capybara::RackTest::Driver.new(TestApp, follow_redirects: false)
185
185
 
186
186
  @driver.visit('/redirect')
@@ -190,36 +190,36 @@ RSpec.describe Capybara::RackTest::Driver do
190
190
  end
191
191
 
192
192
  describe ':redirect_limit option' do
193
- context "with default redirect limit" do
193
+ context 'with default redirect limit' do
194
194
  before do
195
195
  @driver = Capybara::RackTest::Driver.new(TestApp)
196
196
  end
197
197
 
198
- it "should follow 5 redirects" do
199
- @driver.visit("/redirect/5/times")
198
+ it 'should follow 5 redirects' do
199
+ @driver.visit('/redirect/5/times')
200
200
  expect(@driver.html).to include('redirection complete')
201
201
  end
202
202
 
203
- it "should not follow more than 6 redirects" do
203
+ it 'should not follow more than 6 redirects' do
204
204
  expect do
205
- @driver.visit("/redirect/6/times")
205
+ @driver.visit('/redirect/6/times')
206
206
  end.to raise_error(Capybara::InfiniteRedirectError)
207
207
  end
208
208
  end
209
209
 
210
- context "with 21 redirect limit" do
210
+ context 'with 21 redirect limit' do
211
211
  before do
212
212
  @driver = Capybara::RackTest::Driver.new(TestApp, redirect_limit: 21)
213
213
  end
214
214
 
215
- it "should follow 21 redirects" do
216
- @driver.visit("/redirect/21/times")
215
+ it 'should follow 21 redirects' do
216
+ @driver.visit('/redirect/21/times')
217
217
  expect(@driver.html).to include('redirection complete')
218
218
  end
219
219
 
220
- it "should not follow more than 21 redirects" do
220
+ it 'should not follow more than 21 redirects' do
221
221
  expect do
222
- @driver.visit("/redirect/22/times")
222
+ @driver.visit('/redirect/22/times')
223
223
  end.to raise_error(Capybara::InfiniteRedirectError)
224
224
  end
225
225
  end
@@ -235,7 +235,7 @@ end
235
235
  RSpec.describe Capybara::RackTest::CSSHandlers do
236
236
  include CSSHandlerIncludeTester
237
237
 
238
- it "should not be extended by global includes" do
238
+ it 'should not be extended by global includes' do
239
239
  expect(Capybara::RackTest::CSSHandlers.new).not_to respond_to(:dont_extend_css_handler)
240
240
  end
241
241
  end
@@ -18,15 +18,15 @@ RSpec.describe Capybara::Result do
18
18
  string.all '//li', minimum: 0 # pass minimum: 0 so lazy evaluation doesn't get triggered yet
19
19
  end
20
20
 
21
- it "has a length" do
21
+ it 'has a length' do
22
22
  expect(result.length).to eq(4)
23
23
  end
24
24
 
25
- it "has a first element" do
25
+ it 'has a first element' do
26
26
  result.first.text == 'Alpha'
27
27
  end
28
28
 
29
- it "has a last element" do
29
+ it 'has a last element' do
30
30
  result.last.text == 'Delta'
31
31
  end
32
32
 
@@ -34,22 +34,22 @@ RSpec.describe Capybara::Result do
34
34
  expect(result.values_at(0, 2).map(&:text)).to eq(%w[Alpha Gamma])
35
35
  end
36
36
 
37
- it "can return an element by its index" do
37
+ it 'can return an element by its index' do
38
38
  expect(result.at(1).text).to eq('Beta')
39
39
  expect(result[2].text).to eq('Gamma')
40
40
  end
41
41
 
42
- it "can be mapped" do
42
+ it 'can be mapped' do
43
43
  expect(result.map(&:text)).to eq(%w[Alpha Beta Gamma Delta])
44
44
  end
45
45
 
46
- it "can be selected" do
46
+ it 'can be selected' do
47
47
  expect(result.select do |element|
48
48
  element.text.include? 't'
49
49
  end.length).to eq(2)
50
50
  end
51
51
 
52
- it "can be reduced" do
52
+ it 'can be reduced' do
53
53
  expect(result.reduce('') do |memo, element|
54
54
  memo + element.text[0]
55
55
  end).to eq('ABGD')
@@ -82,7 +82,7 @@ RSpec.describe Capybara::Result do
82
82
  it 'should catch invalid element errors during filtering' do
83
83
  allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
84
84
  allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
85
- instance_double("Capybara::Session", driver: instance_double("Capybara::Driver::Base", invalid_element_errors: [StandardError]))
85
+ instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [StandardError]))
86
86
  )
87
87
  result = string.all('//li', text: 'Alpha')
88
88
  expect(result.size).to eq 0
@@ -91,7 +91,7 @@ RSpec.describe Capybara::Result do
91
91
  it 'should return non-invalid element errors during filtering' do
92
92
  allow_any_instance_of(Capybara::Node::Simple).to receive(:text).and_raise(StandardError)
93
93
  allow_any_instance_of(Capybara::Node::Simple).to receive(:session).and_return(
94
- instance_double("Capybara::Session", driver: instance_double("Capybara::Driver::Base", invalid_element_errors: [ArgumentError]))
94
+ instance_double('Capybara::Session', driver: instance_double('Capybara::Driver::Base', invalid_element_errors: [ArgumentError]))
95
95
  )
96
96
  expect do
97
97
  string.all('//li', text: 'Alpha').to_a
@@ -99,7 +99,7 @@ RSpec.describe Capybara::Result do
99
99
  end
100
100
 
101
101
  # Not a great test but it indirectly tests what is needed
102
- it "should evaluate filters lazily for idx" do
102
+ it 'should evaluate filters lazily for idx' do
103
103
  skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
104
104
  # Not processed until accessed
105
105
  expect(result.instance_variable_get('@result_cache').size).to be 0
@@ -120,7 +120,7 @@ RSpec.describe Capybara::Result do
120
120
  expect(result.instance_variable_get('@result_cache').size).to eq 4
121
121
  end
122
122
 
123
- it "should evaluate filters lazily for range" do
123
+ it 'should evaluate filters lazily for range' do
124
124
  skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
125
125
  result[0..1]
126
126
  expect(result.instance_variable_get('@result_cache').size).to be 2
@@ -129,7 +129,7 @@ RSpec.describe Capybara::Result do
129
129
  expect(result.instance_variable_get('@result_cache').size).to be 4
130
130
  end
131
131
 
132
- it "should evaluate filters lazily for idx and length" do
132
+ it 'should evaluate filters lazily for idx and length' do
133
133
  skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
134
134
  result[1, 2]
135
135
  expect(result.instance_variable_get('@result_cache').size).to be 3
@@ -138,13 +138,13 @@ RSpec.describe Capybara::Result do
138
138
  expect(result.instance_variable_get('@result_cache').size).to be 4
139
139
  end
140
140
 
141
- it "should only need to evaluate one result for any?" do
141
+ it 'should only need to evaluate one result for any?' do
142
142
  skip 'JRuby has an issue with lazy enumerator evaluation' if RUBY_PLATFORM == 'java'
143
143
  result.any?
144
144
  expect(result.instance_variable_get('@result_cache').size).to be 1
145
145
  end
146
146
 
147
- it "should evaluate all elements when #to_a called" do
147
+ it 'should evaluate all elements when #to_a called' do
148
148
  # All cached when converted to array
149
149
  result.to_a
150
150
  expect(result.instance_variable_get('@result_cache').size).to eq 4
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
  require 'capybara/rspec'
5
5
 
6
- RSpec.configuration.before(:each, file_path: "./spec/rspec/features_spec.rb") do
6
+ RSpec.configuration.before(:each, file_path: './spec/rspec/features_spec.rb') do
7
7
  @in_filtered_hook = true
8
8
  end
9
9
 
@@ -12,25 +12,25 @@ feature "Capybara's feature DSL" do
12
12
  @in_background = true
13
13
  end
14
14
 
15
- scenario "includes Capybara" do
15
+ scenario 'includes Capybara' do
16
16
  visit('/')
17
17
  expect(page).to have_content('Hello world!')
18
18
  end
19
19
 
20
- scenario "preserves description" do |ex|
20
+ scenario 'preserves description' do |ex|
21
21
  expect(ex.metadata[:full_description])
22
22
  .to eq("Capybara's feature DSL preserves description")
23
23
  end
24
24
 
25
- scenario "allows driver switching", driver: :selenium do
25
+ scenario 'allows driver switching', driver: :selenium do
26
26
  expect(Capybara.current_driver).to eq(:selenium)
27
27
  end
28
28
 
29
- scenario "runs background" do
29
+ scenario 'runs background' do
30
30
  expect(@in_background).to be_truthy
31
31
  end
32
32
 
33
- scenario "runs hooks filtered by file path" do
33
+ scenario 'runs hooks filtered by file path' do
34
34
  expect(@in_filtered_hook).to be_truthy
35
35
  end
36
36
 
@@ -54,7 +54,7 @@ feature "Capybara's feature DSL" do
54
54
  end
55
55
  end
56
56
 
57
- feature "given and given! aliases to let and let!" do
57
+ feature 'given and given! aliases to let and let!' do
58
58
  given(:value) { :available }
59
59
  given!(:value_in_background) { :available }
60
60
 
@@ -62,20 +62,20 @@ feature "given and given! aliases to let and let!" do
62
62
  expect(value_in_background).to be(:available)
63
63
  end
64
64
 
65
- scenario "given and given! work as intended" do
65
+ scenario 'given and given! work as intended' do
66
66
  expect(value).to be(:available)
67
67
  expect(value_in_background).to be(:available)
68
68
  end
69
69
  end
70
70
 
71
71
  feature "Capybara's feature DSL with driver", driver: :culerity do
72
- scenario "switches driver" do
72
+ scenario 'switches driver' do
73
73
  expect(Capybara.current_driver).to eq(:culerity)
74
74
  end
75
75
  end
76
76
 
77
77
  # rubocop:disable RSpec/RepeatedExample
78
- xfeature "if xfeature aliases to pending then" do
78
+ xfeature 'if xfeature aliases to pending then' do
79
79
  scenario "this should be 'temporarily disabled with xfeature'" do
80
80
  # dummy
81
81
  end
@@ -84,12 +84,12 @@ xfeature "if xfeature aliases to pending then" do
84
84
  end
85
85
  end
86
86
 
87
- ffeature "if ffeature aliases focused tag then" do # rubocop:disable RSpec/Focus
88
- scenario "scenario inside this feature has metatag focus tag" do |example|
87
+ ffeature 'if ffeature aliases focused tag then' do # rubocop:disable RSpec/Focus
88
+ scenario 'scenario inside this feature has metatag focus tag' do |example|
89
89
  expect(example.metadata[:focus]).to eq true
90
90
  end
91
91
 
92
- scenario "other scenarios also has metatag focus tag " do |example|
92
+ scenario 'other scenarios also has metatag focus tag ' do |example|
93
93
  expect(example.metadata[:focus]).to eq true
94
94
  end
95
95
  end
@@ -3,17 +3,17 @@
3
3
  require 'spec_helper'
4
4
  require 'capybara/rspec'
5
5
 
6
- RSpec.configuration.before(:each, file_path: "./spec/rspec/scenarios_spec.rb") do
6
+ RSpec.configuration.before(:each, file_path: './spec/rspec/scenarios_spec.rb') do
7
7
  @in_filtered_hook = true
8
8
  end
9
9
 
10
- feature "if fscenario aliases focused tag then" do
11
- fscenario "scenario should have focused meta tag" do |example| # rubocop:disable RSpec/Focus
10
+ feature 'if fscenario aliases focused tag then' do
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
15
15
 
16
- feature "if xscenario aliases to pending then" do
16
+ feature 'if xscenario aliases to pending then' do
17
17
  xscenario "this test should be 'temporarily disabled with xscenario'" do
18
18
  end
19
19
  end
@@ -11,105 +11,105 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
11
11
  include Capybara::DSL
12
12
  include Capybara::RSpecMatchers
13
13
 
14
- describe "have_css matcher" do
15
- it "gives proper description" do
16
- expect(have_css('h1').description).to eq("have visible css \"h1\"")
14
+ describe 'have_css matcher' do
15
+ it 'gives proper description' do
16
+ expect(have_css('h1').description).to eq('have visible css "h1"')
17
17
  end
18
18
 
19
- context "on a string" do
20
- context "with should" do
21
- it "passes if has_css? returns true" do
22
- expect("<h1>Text</h1>").to have_css('h1')
19
+ context 'on a string' do
20
+ context 'with should' do
21
+ it 'passes if has_css? returns true' do
22
+ expect('<h1>Text</h1>').to have_css('h1')
23
23
  end
24
24
 
25
- it "fails if has_css? returns false" do
25
+ it 'fails if has_css? returns false' do
26
26
  expect do
27
- expect("<h1>Text</h1>").to have_css('h2')
28
- end.to raise_error(/expected to find visible css "h2" but there were no matches/)
27
+ expect('<h1>Text</h1>').to have_css('h2')
28
+ end.to raise_error(/expected to find css "h2" but there were no matches/)
29
29
  end
30
30
 
31
- it "passes if matched node count equals expected count" do
32
- expect("<h1>Text</h1>").to have_css('h1', count: 1)
31
+ it 'passes if matched node count equals expected count' do
32
+ expect('<h1>Text</h1>').to have_css('h1', count: 1)
33
33
  end
34
34
 
35
- it "fails if matched node count does not equal expected count" do
35
+ it 'fails if matched node count does not equal expected count' do
36
36
  expect do
37
- expect("<h1>Text</h1>").to have_css('h1', count: 2)
38
- end.to raise_error("expected to find visible css \"h1\" 2 times, found 1 match: \"Text\"")
37
+ expect('<h1>Text</h1>').to have_css('h1', count: 2)
38
+ end.to raise_error('expected to find visible css "h1" 2 times, found 1 match: "Text"')
39
39
  end
40
40
 
41
- it "fails if matched node count is less than expected minimum count" do
41
+ it 'fails if matched node count is less than expected minimum count' do
42
42
  expect do
43
- expect("<h1>Text</h1>").to have_css('p', minimum: 1)
44
- end.to raise_error("expected to find visible css \"p\" at least 1 time but there were no matches")
43
+ expect('<h1>Text</h1>').to have_css('p', minimum: 1)
44
+ end.to raise_error('expected to find css "p" at least 1 time but there were no matches')
45
45
  end
46
46
 
47
- it "fails if matched node count is more than expected maximum count" do
47
+ it 'fails if matched node count is more than expected maximum count' do
48
48
  expect do
49
- expect("<h1>Text</h1><h1>Text</h1><h1>Text</h1>").to have_css('h1', maximum: 2)
49
+ expect('<h1>Text</h1><h1>Text</h1><h1>Text</h1>').to have_css('h1', maximum: 2)
50
50
  end.to raise_error('expected to find visible css "h1" at most 2 times, found 3 matches: "Text", "Text", "Text"')
51
51
  end
52
52
 
53
- it "fails if matched node count does not belong to expected range" do
53
+ it 'fails if matched node count does not belong to expected range' do
54
54
  expect do
55
- expect("<h1>Text</h1>").to have_css('h1', between: 2..3)
56
- end.to raise_error("expected to find visible css \"h1\" between 2 and 3 times, found 1 match: \"Text\"")
55
+ expect('<h1>Text</h1>').to have_css('h1', between: 2..3)
56
+ end.to raise_error('expected to find visible css "h1" between 2 and 3 times, found 1 match: "Text"')
57
57
  end
58
58
  end
59
59
 
60
- context "with should_not" do
61
- it "passes if has_no_css? returns true" do
62
- expect("<h1>Text</h1>").not_to have_css('h2')
60
+ context 'with should_not' do
61
+ it 'passes if has_no_css? returns true' do
62
+ expect('<h1>Text</h1>').not_to have_css('h2')
63
63
  end
64
64
 
65
- it "fails if has_no_css? returns false" do
65
+ it 'fails if has_no_css? returns false' do
66
66
  expect do
67
- expect("<h1>Text</h1>").not_to have_css('h1')
67
+ expect('<h1>Text</h1>').not_to have_css('h1')
68
68
  end.to raise_error(/expected not to find visible css "h1"/)
69
69
  end
70
70
 
71
- it "passes if matched node count does not equal expected count" do
72
- expect("<h1>Text</h1>").not_to have_css('h1', count: 2)
71
+ it 'passes if matched node count does not equal expected count' do
72
+ expect('<h1>Text</h1>').not_to have_css('h1', count: 2)
73
73
  end
74
74
 
75
- it "fails if matched node count equals expected count" do
75
+ it 'fails if matched node count equals expected count' do
76
76
  expect do
77
- expect("<h1>Text</h1>").not_to have_css('h1', count: 1)
77
+ expect('<h1>Text</h1>').not_to have_css('h1', count: 1)
78
78
  end.to raise_error(/expected not to find visible css "h1"/)
79
79
  end
80
80
  end
81
81
 
82
- it "supports compounding" do
83
- expect("<h1>Text</h1><h2>Text</h2>").to have_css('h1').and have_css('h2')
84
- expect("<h1>Text</h1><h2>Text</h2>").to have_css('h3').or have_css('h1')
85
- expect("<h1>Text</h1><h2>Text</h2>").to have_no_css('h4').and have_css('h2')
86
- expect("<h1>Text</h1><h2>Text</h2>").to have_no_css('h2').or have_css('h1')
82
+ it 'supports compounding' do
83
+ expect('<h1>Text</h1><h2>Text</h2>').to have_css('h1').and have_css('h2')
84
+ expect('<h1>Text</h1><h2>Text</h2>').to have_css('h3').or have_css('h1')
85
+ expect('<h1>Text</h1><h2>Text</h2>').to have_no_css('h4').and have_css('h2')
86
+ expect('<h1>Text</h1><h2>Text</h2>').to have_no_css('h2').or have_css('h1')
87
87
  end
88
88
  end
89
89
 
90
- context "on a page or node" do
90
+ context 'on a page or node' do
91
91
  before do
92
92
  visit('/with_html')
93
93
  end
94
94
 
95
- context "with should" do
96
- it "passes if has_css? returns true" do
95
+ context 'with should' do
96
+ it 'passes if has_css? returns true' do
97
97
  expect(page).to have_css('h1')
98
98
  end
99
99
 
100
- it "fails if has_css? returns false" do
100
+ it 'fails if has_css? returns false' do
101
101
  expect do
102
102
  expect(page).to have_css('h1#doesnotexist')
103
- end.to raise_error(/expected to find visible css "h1#doesnotexist" but there were no matches/)
103
+ end.to raise_error(/expected to find css "h1#doesnotexist" but there were no matches/)
104
104
  end
105
105
  end
106
106
 
107
- context "with should_not" do
108
- it "passes if has_no_css? returns true" do
107
+ context 'with should_not' do
108
+ it 'passes if has_no_css? returns true' do
109
109
  expect(page).not_to have_css('h1#doesnotexist')
110
110
  end
111
111
 
112
- it "fails if has_no_css? returns false" do
112
+ it 'fails if has_no_css? returns false' do
113
113
  expect do
114
114
  expect(page).not_to have_css('h1')
115
115
  end.to raise_error(/expected not to find visible css "h1"/)
@@ -118,67 +118,67 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
118
118
  end
119
119
  end
120
120
 
121
- describe "have_xpath matcher" do
122
- it "gives proper description" do
121
+ describe 'have_xpath matcher' do
122
+ it 'gives proper description' do
123
123
  expect(have_xpath('//h1').description).to eq("have visible xpath \"\/\/h1\"")
124
124
  end
125
125
 
126
- context "on a string" do
127
- context "with should" do
128
- it "passes if has_xpath? returns true" do
129
- expect("<h1>Text</h1>").to have_xpath('//h1')
126
+ context 'on a string' do
127
+ context 'with should' do
128
+ it 'passes if has_xpath? returns true' do
129
+ expect('<h1>Text</h1>').to have_xpath('//h1')
130
130
  end
131
131
 
132
- it "fails if has_xpath? returns false" do
132
+ it 'fails if has_xpath? returns false' do
133
133
  expect do
134
- expect("<h1>Text</h1>").to have_xpath('//h2')
135
- end.to raise_error(%r{expected to find visible xpath "//h2" but there were no matches})
134
+ expect('<h1>Text</h1>').to have_xpath('//h2')
135
+ end.to raise_error(%r{expected to find xpath "//h2" but there were no matches})
136
136
  end
137
137
  end
138
138
 
139
- context "with should_not" do
140
- it "passes if has_no_xpath? returns true" do
141
- expect("<h1>Text</h1>").not_to have_xpath('//h2')
139
+ context 'with should_not' do
140
+ it 'passes if has_no_xpath? returns true' do
141
+ expect('<h1>Text</h1>').not_to have_xpath('//h2')
142
142
  end
143
143
 
144
- it "fails if has_no_xpath? returns false" do
144
+ it 'fails if has_no_xpath? returns false' do
145
145
  expect do
146
- expect("<h1>Text</h1>").not_to have_xpath('//h1')
146
+ expect('<h1>Text</h1>').not_to have_xpath('//h1')
147
147
  end.to raise_error(%r{expected not to find visible xpath "//h1"})
148
148
  end
149
149
  end
150
150
 
151
- it "supports compounding" do
152
- expect("<h1>Text</h1><h2>Text</h2>").to have_xpath('//h1').and have_xpath('//h2')
153
- expect("<h1>Text</h1><h2>Text</h2>").to have_xpath('//h3').or have_xpath('//h1')
154
- expect("<h1>Text</h1><h2>Text</h2>").to have_no_xpath('//h4').and have_xpath('//h1')
155
- expect("<h1>Text</h1><h2>Text</h2>").to have_no_xpath('//h4').or have_xpath('//h4')
151
+ it 'supports compounding' do
152
+ expect('<h1>Text</h1><h2>Text</h2>').to have_xpath('//h1').and have_xpath('//h2')
153
+ expect('<h1>Text</h1><h2>Text</h2>').to have_xpath('//h3').or have_xpath('//h1')
154
+ expect('<h1>Text</h1><h2>Text</h2>').to have_no_xpath('//h4').and have_xpath('//h1')
155
+ expect('<h1>Text</h1><h2>Text</h2>').to have_no_xpath('//h4').or have_xpath('//h4')
156
156
  end
157
157
  end
158
158
 
159
- context "on a page or node" do
159
+ context 'on a page or node' do
160
160
  before do
161
161
  visit('/with_html')
162
162
  end
163
163
 
164
- context "with should" do
165
- it "passes if has_xpath? returns true" do
164
+ context 'with should' do
165
+ it 'passes if has_xpath? returns true' do
166
166
  expect(page).to have_xpath('//h1')
167
167
  end
168
168
 
169
- it "fails if has_xpath? returns false" do
169
+ it 'fails if has_xpath? returns false' do
170
170
  expect do
171
171
  expect(page).to have_xpath("//h1[@id='doesnotexist']")
172
- end.to raise_error(%r{expected to find visible xpath "//h1\[@id='doesnotexist'\]" but there were no matches})
172
+ end.to raise_error(%r{expected to find xpath "//h1\[@id='doesnotexist'\]" but there were no matches})
173
173
  end
174
174
  end
175
175
 
176
- context "with should_not" do
177
- it "passes if has_no_xpath? returns true" do
176
+ context 'with should_not' do
177
+ it 'passes if has_no_xpath? returns true' do
178
178
  expect(page).not_to have_xpath('//h1[@id="doesnotexist"]')
179
179
  end
180
180
 
181
- it "fails if has_no_xpath? returns false" do
181
+ it 'fails if has_no_xpath? returns false' do
182
182
  expect do
183
183
  expect(page).not_to have_xpath('//h1')
184
184
  end.to raise_error(%r{expected not to find visible xpath "//h1"})
@@ -187,68 +187,68 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
187
187
  end
188
188
  end
189
189
 
190
- describe "have_selector matcher" do
191
- it "gives proper description" do
190
+ describe 'have_selector matcher' do
191
+ it 'gives proper description' do
192
192
  matcher = have_selector('//h1')
193
- expect("<h1>Text</h1>").to matcher
194
- expect(matcher.description).to eq("have visible xpath \"//h1\"")
193
+ expect('<h1>Text</h1>').to matcher
194
+ expect(matcher.description).to eq('have visible xpath "//h1"')
195
195
  end
196
196
 
197
- context "on a string" do
198
- context "with should" do
199
- it "passes if has_selector? returns true" do
200
- expect("<h1>Text</h1>").to have_selector('//h1')
197
+ context 'on a string' do
198
+ context 'with should' do
199
+ it 'passes if has_selector? returns true' do
200
+ expect('<h1>Text</h1>').to have_selector('//h1')
201
201
  end
202
202
 
203
- it "fails if has_selector? returns false" do
203
+ it 'fails if has_selector? returns false' do
204
204
  expect do
205
- expect("<h1>Text</h1>").to have_selector('//h2')
206
- end.to raise_error(%r{expected to find visible xpath "//h2" but there were no matches})
205
+ expect('<h1>Text</h1>').to have_selector('//h2')
206
+ end.to raise_error(%r{expected to find xpath "//h2" but there were no matches})
207
207
  end
208
208
  end
209
209
 
210
- context "with should_not" do
211
- it "passes if has_no_selector? returns true" do
212
- expect("<h1>Text</h1>").not_to have_selector(:css, 'h2')
210
+ context 'with should_not' do
211
+ it 'passes if has_no_selector? returns true' do
212
+ expect('<h1>Text</h1>').not_to have_selector(:css, 'h2')
213
213
  end
214
214
 
215
- it "fails if has_no_selector? returns false" do
215
+ it 'fails if has_no_selector? returns false' do
216
216
  expect do
217
- expect("<h1>Text</h1>").not_to have_selector(:css, 'h1')
217
+ expect('<h1>Text</h1>').not_to have_selector(:css, 'h1')
218
218
  end.to raise_error(/expected not to find visible css "h1"/)
219
219
  end
220
220
  end
221
221
  end
222
222
 
223
- context "on a page or node" do
223
+ context 'on a page or node' do
224
224
  before do
225
225
  visit('/with_html')
226
226
  end
227
227
 
228
- context "with should" do
229
- it "passes if has_selector? returns true" do
228
+ context 'with should' do
229
+ it 'passes if has_selector? returns true' do
230
230
  expect(page).to have_selector('//h1', text: 'test')
231
231
  end
232
232
 
233
- it "fails if has_selector? returns false" do
233
+ it 'fails if has_selector? returns false' do
234
234
  expect do
235
235
  expect(page).to have_selector("//h1[@id='doesnotexist']")
236
- end.to raise_error(%r{expected to find visible xpath "//h1\[@id='doesnotexist'\]" but there were no matches})
236
+ end.to raise_error(%r{expected to find xpath "//h1\[@id='doesnotexist'\]" but there were no matches})
237
237
  end
238
238
 
239
- it "includes text in error message" do
239
+ it 'includes text in error message' do
240
240
  expect do
241
- expect(page).to have_selector("//h1", text: 'wrong text')
241
+ expect(page).to have_selector('//h1', text: 'wrong text')
242
242
  end.to raise_error(%r{expected to find visible xpath "//h1" with text "wrong text" but there were no matches})
243
243
  end
244
244
  end
245
245
 
246
- context "with should_not" do
247
- it "passes if has_no_css? returns true" do
246
+ context 'with should_not' do
247
+ it 'passes if has_no_css? returns true' do
248
248
  expect(page).not_to have_selector(:css, 'h1#doesnotexist')
249
249
  end
250
250
 
251
- it "fails if has_no_selector? returns false" do
251
+ it 'fails if has_no_selector? returns false' do
252
252
  expect do
253
253
  expect(page).not_to have_selector(:css, 'h1', text: 'test')
254
254
  end.to raise_error(/expected not to find visible css "h1" with text "test"/)
@@ -256,76 +256,76 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
256
256
  end
257
257
  end
258
258
 
259
- it "supports compounding" do
260
- expect("<h1>Text</h1><h2>Text</h2>").to have_selector('//h1').and have_selector('//h2')
261
- expect("<h1>Text</h1><h2>Text</h2>").to have_selector('//h3').or have_selector('//h1')
262
- expect("<h1>Text</h1><h2>Text</h2>").to have_no_selector('//h3').and have_selector('//h1')
259
+ it 'supports compounding' do
260
+ expect('<h1>Text</h1><h2>Text</h2>').to have_selector('//h1').and have_selector('//h2')
261
+ expect('<h1>Text</h1><h2>Text</h2>').to have_selector('//h3').or have_selector('//h1')
262
+ expect('<h1>Text</h1><h2>Text</h2>').to have_no_selector('//h3').and have_selector('//h1')
263
263
  end
264
264
  end
265
265
 
266
- describe "have_content matcher" do
267
- it "gives proper description" do
268
- expect(have_content('Text').description).to eq("text \"Text\"")
266
+ describe 'have_content matcher' do
267
+ it 'gives proper description' do
268
+ expect(have_content('Text').description).to eq('text "Text"')
269
269
  end
270
270
 
271
- context "on a string" do
272
- context "with should" do
273
- it "passes if has_content? returns true" do
274
- expect("<h1>Text</h1>").to have_content('Text')
271
+ context 'on a string' do
272
+ context 'with should' do
273
+ it 'passes if has_content? returns true' do
274
+ expect('<h1>Text</h1>').to have_content('Text')
275
275
  end
276
276
 
277
- it "passes if has_content? returns true using regexp" do
278
- expect("<h1>Text</h1>").to have_content(/ext/)
277
+ it 'passes if has_content? returns true using regexp' do
278
+ expect('<h1>Text</h1>').to have_content(/ext/)
279
279
  end
280
280
 
281
- it "fails if has_content? returns false" do
281
+ it 'fails if has_content? returns false' do
282
282
  expect do
283
- expect("<h1>Text</h1>").to have_content('No such Text')
283
+ expect('<h1>Text</h1>').to have_content('No such Text')
284
284
  end.to raise_error(/expected to find text "No such Text" in "Text"/)
285
285
  end
286
286
  end
287
287
 
288
- context "with should_not" do
289
- it "passes if has_no_content? returns true" do
290
- expect("<h1>Text</h1>").not_to have_content('No such Text')
288
+ context 'with should_not' do
289
+ it 'passes if has_no_content? returns true' do
290
+ expect('<h1>Text</h1>').not_to have_content('No such Text')
291
291
  end
292
292
 
293
- it "passes because escapes any characters that would have special meaning in a regexp" do
294
- expect("<h1>Text</h1>").not_to have_content('.')
293
+ it 'passes because escapes any characters that would have special meaning in a regexp' do
294
+ expect('<h1>Text</h1>').not_to have_content('.')
295
295
  end
296
296
 
297
- it "fails if has_no_content? returns false" do
297
+ it 'fails if has_no_content? returns false' do
298
298
  expect do
299
- expect("<h1>Text</h1>").not_to have_content('Text')
299
+ expect('<h1>Text</h1>').not_to have_content('Text')
300
300
  end.to raise_error(/expected not to find text "Text" in "Text"/)
301
301
  end
302
302
  end
303
303
  end
304
304
 
305
- context "on a page or node" do
305
+ context 'on a page or node' do
306
306
  before do
307
307
  visit('/with_html')
308
308
  end
309
309
 
310
- context "with should" do
311
- it "passes if has_content? returns true" do
310
+ context 'with should' do
311
+ it 'passes if has_content? returns true' do
312
312
  expect(page).to have_content('This is a test')
313
313
  end
314
314
 
315
- it "passes if has_content? returns true using regexp" do
315
+ it 'passes if has_content? returns true using regexp' do
316
316
  expect(page).to have_content(/test/)
317
317
  end
318
318
 
319
- it "fails if has_content? returns false" do
319
+ it 'fails if has_content? returns false' do
320
320
  expect do
321
321
  expect(page).to have_content('No such Text')
322
322
  end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
323
323
  end
324
324
 
325
- context "with default selector CSS" do
325
+ context 'with default selector CSS' do
326
326
  before { Capybara.default_selector = :css }
327
327
 
328
- it "fails if has_content? returns false" do
328
+ it 'fails if has_content? returns false' do
329
329
  expect do
330
330
  expect(page).to have_content('No such Text')
331
331
  end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
@@ -334,12 +334,12 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
334
334
  end
335
335
  end
336
336
 
337
- context "with should_not" do
338
- it "passes if has_no_content? returns true" do
337
+ context 'with should_not' do
338
+ it 'passes if has_no_content? returns true' do
339
339
  expect(page).not_to have_content('No such Text')
340
340
  end
341
341
 
342
- it "fails if has_no_content? returns false" do
342
+ it 'fails if has_no_content? returns false' do
343
343
  expect do
344
344
  expect(page).not_to have_content('This is a test')
345
345
  end.to raise_error(/expected not to find text "This is a test"/)
@@ -347,121 +347,121 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
347
347
  end
348
348
  end
349
349
 
350
- it "supports compounding" do
351
- expect("<h1>Text</h1><h2>And</h2>").to have_content('Text').and have_content('And')
352
- expect("<h1>Text</h1><h2>Or</h2>").to have_content('XYZ').or have_content('Or')
353
- expect("<h1>Text</h1><h2>Or</h2>").to have_no_content('XYZ').and have_content('Or')
350
+ it 'supports compounding' do
351
+ expect('<h1>Text</h1><h2>And</h2>').to have_content('Text').and have_content('And')
352
+ expect('<h1>Text</h1><h2>Or</h2>').to have_content('XYZ').or have_content('Or')
353
+ expect('<h1>Text</h1><h2>Or</h2>').to have_no_content('XYZ').and have_content('Or')
354
354
  end
355
355
  end
356
356
 
357
- describe "have_text matcher" do
358
- it "gives proper description" do
359
- expect(have_text('Text').description).to eq("text \"Text\"")
357
+ describe 'have_text matcher' do
358
+ it 'gives proper description' do
359
+ expect(have_text('Text').description).to eq('text "Text"')
360
360
  end
361
361
 
362
- context "on a string" do
363
- context "with should" do
364
- it "passes if text contains given string" do
365
- expect("<h1>Text</h1>").to have_text('Text')
362
+ context 'on a string' do
363
+ context 'with should' do
364
+ it 'passes if text contains given string' do
365
+ expect('<h1>Text</h1>').to have_text('Text')
366
366
  end
367
367
 
368
- it "passes if text matches given regexp" do
369
- expect("<h1>Text</h1>").to have_text(/ext/)
368
+ it 'passes if text matches given regexp' do
369
+ expect('<h1>Text</h1>').to have_text(/ext/)
370
370
  end
371
371
 
372
372
  it "fails if text doesn't contain given string" do
373
373
  expect do
374
- expect("<h1>Text</h1>").to have_text('No such Text')
374
+ expect('<h1>Text</h1>').to have_text('No such Text')
375
375
  end.to raise_error(/expected to find text "No such Text" in "Text"/)
376
376
  end
377
377
 
378
378
  it "fails if text doesn't match given regexp" do
379
379
  expect do
380
- expect("<h1>Text</h1>").to have_text(/No such Text/)
380
+ expect('<h1>Text</h1>').to have_text(/No such Text/)
381
381
  end.to raise_error('expected to find text matching /No such Text/ in "Text"')
382
382
  end
383
383
 
384
- it "casts Integer to string" do
384
+ it 'casts Integer to string' do
385
385
  expect do
386
- expect("<h1>Text</h1>").to have_text(3)
386
+ expect('<h1>Text</h1>').to have_text(3)
387
387
  end.to raise_error(/expected to find text "3" in "Text"/)
388
388
  end
389
389
 
390
- it "fails if matched text count does not equal to expected count" do
390
+ it 'fails if matched text count does not equal to expected count' do
391
391
  expect do
392
- expect("<h1>Text</h1>").to have_text('Text', count: 2)
392
+ expect('<h1>Text</h1>').to have_text('Text', count: 2)
393
393
  end.to raise_error('expected to find text "Text" 2 times but found 1 time in "Text"')
394
394
  end
395
395
 
396
- it "fails if matched text count is less than expected minimum count" do
396
+ it 'fails if matched text count is less than expected minimum count' do
397
397
  expect do
398
- expect("<h1>Text</h1>").to have_text('Lorem', minimum: 1)
398
+ expect('<h1>Text</h1>').to have_text('Lorem', minimum: 1)
399
399
  end.to raise_error('expected to find text "Lorem" at least 1 time but found 0 times in "Text"')
400
400
  end
401
401
 
402
- it "fails if matched text count is more than expected maximum count" do
402
+ it 'fails if matched text count is more than expected maximum count' do
403
403
  expect do
404
- expect("<h1>Text TextText</h1>").to have_text('Text', maximum: 2)
404
+ expect('<h1>Text TextText</h1>').to have_text('Text', maximum: 2)
405
405
  end.to raise_error('expected to find text "Text" at most 2 times but found 3 times in "Text TextText"')
406
406
  end
407
407
 
408
- it "fails if matched text count does not belong to expected range" do
408
+ it 'fails if matched text count does not belong to expected range' do
409
409
  expect do
410
- expect("<h1>Text</h1>").to have_text('Text', between: 2..3)
410
+ expect('<h1>Text</h1>').to have_text('Text', between: 2..3)
411
411
  end.to raise_error('expected to find text "Text" between 2 and 3 times but found 1 time in "Text"')
412
412
  end
413
413
  end
414
414
 
415
- context "with should_not" do
415
+ context 'with should_not' do
416
416
  it "passes if text doesn't contain a string" do
417
- expect("<h1>Text</h1>").not_to have_text('No such Text')
417
+ expect('<h1>Text</h1>').not_to have_text('No such Text')
418
418
  end
419
419
 
420
- it "passes because escapes any characters that would have special meaning in a regexp" do
421
- expect("<h1>Text</h1>").not_to have_text('.')
420
+ it 'passes because escapes any characters that would have special meaning in a regexp' do
421
+ expect('<h1>Text</h1>').not_to have_text('.')
422
422
  end
423
423
 
424
- it "fails if text contains a string" do
424
+ it 'fails if text contains a string' do
425
425
  expect do
426
- expect("<h1>Text</h1>").not_to have_text('Text')
426
+ expect('<h1>Text</h1>').not_to have_text('Text')
427
427
  end.to raise_error(/expected not to find text "Text" in "Text"/)
428
428
  end
429
429
  end
430
430
  end
431
431
 
432
- context "on a page or node" do
432
+ context 'on a page or node' do
433
433
  before do
434
434
  visit('/with_html')
435
435
  end
436
436
 
437
- context "with should" do
438
- it "passes if has_text? returns true" do
437
+ context 'with should' do
438
+ it 'passes if has_text? returns true' do
439
439
  expect(page).to have_text('This is a test')
440
440
  end
441
441
 
442
- it "passes if has_text? returns true using regexp" do
442
+ it 'passes if has_text? returns true using regexp' do
443
443
  expect(page).to have_text(/test/)
444
444
  end
445
445
 
446
- it "can check for all text" do
446
+ it 'can check for all text' do
447
447
  expect(page).to have_text(:all, 'Some of this text is hidden!')
448
448
  end
449
449
 
450
- it "can check for visible text" do
450
+ it 'can check for visible text' do
451
451
  expect(page).to have_text(:visible, 'Some of this text is')
452
452
  expect(page).not_to have_text(:visible, 'Some of this text is hidden!')
453
453
  end
454
454
 
455
- it "fails if has_text? returns false" do
455
+ it 'fails if has_text? returns false' do
456
456
  expect do
457
457
  expect(page).to have_text('No such Text')
458
458
  end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
459
459
  end
460
460
 
461
- context "with default selector CSS" do
461
+ context 'with default selector CSS' do
462
462
  before { Capybara.default_selector = :css }
463
463
 
464
- it "fails if has_text? returns false" do
464
+ it 'fails if has_text? returns false' do
465
465
  expect do
466
466
  expect(page).to have_text('No such Text')
467
467
  end.to raise_error(/expected to find text "No such Text" in "(.*)This is a test(.*)"/)
@@ -470,12 +470,12 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
470
470
  end
471
471
  end
472
472
 
473
- context "with should_not" do
474
- it "passes if has_no_text? returns true" do
473
+ context 'with should_not' do
474
+ it 'passes if has_no_text? returns true' do
475
475
  expect(page).not_to have_text('No such Text')
476
476
  end
477
477
 
478
- it "fails if has_no_text? returns false" do
478
+ it 'fails if has_no_text? returns false' do
479
479
  expect do
480
480
  expect(page).not_to have_text('This is a test')
481
481
  end.to raise_error(/expected not to find text "This is a test"/)
@@ -483,49 +483,49 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
483
483
  end
484
484
  end
485
485
 
486
- it "supports compounding" do
487
- expect("<h1>Text</h1><h2>And</h2>").to have_text('Text').and have_text('And')
488
- expect("<h1>Text</h1><h2>Or</h2>").to have_text('Not here').or have_text('Or')
486
+ it 'supports compounding' do
487
+ expect('<h1>Text</h1><h2>And</h2>').to have_text('Text').and have_text('And')
488
+ expect('<h1>Text</h1><h2>Or</h2>').to have_text('Not here').or have_text('Or')
489
489
  end
490
490
  end
491
491
 
492
- describe "have_link matcher" do
492
+ describe 'have_link matcher' do
493
493
  let(:html) { '<a href="#">Just a link</a><a href="#">Another link</a>' }
494
494
 
495
- it "gives proper description" do
496
- expect(have_link('Just a link').description).to eq("have visible link \"Just a link\"")
495
+ it 'gives proper description' do
496
+ expect(have_link('Just a link').description).to eq('have visible link "Just a link"')
497
497
  end
498
498
 
499
- it "passes if there is such a button" do
499
+ it 'passes if there is such a button' do
500
500
  expect(html).to have_link('Just a link')
501
501
  end
502
502
 
503
- it "fails if there is no such button" do
503
+ it 'fails if there is no such button' do
504
504
  expect do
505
505
  expect(html).to have_link('No such Link')
506
- end.to raise_error(/expected to find visible link "No such Link"/)
506
+ end.to raise_error(/expected to find link "No such Link"/)
507
507
  end
508
508
 
509
- it "supports compounding" do
509
+ it 'supports compounding' do
510
510
  expect(html).to have_link('Just a link').and have_link('Another link')
511
511
  expect(html).to have_link('Not a link').or have_link('Another link')
512
512
  expect(html).to have_no_link('Not a link').and have_link('Another link')
513
513
  end
514
514
  end
515
515
 
516
- describe "have_title matcher" do
517
- it "gives proper description" do
518
- expect(have_title('Just a title').description).to eq("have title \"Just a title\"")
516
+ describe 'have_title matcher' do
517
+ it 'gives proper description' do
518
+ expect(have_title('Just a title').description).to eq('have title "Just a title"')
519
519
  end
520
520
 
521
- context "on a string" do
521
+ context 'on a string' do
522
522
  let(:html) { '<title>Just a title</title>' }
523
523
 
524
- it "passes if there is such a title" do
524
+ it 'passes if there is such a title' do
525
525
  expect(html).to have_title('Just a title')
526
526
  end
527
527
 
528
- it "fails if there is no such title" do
528
+ it 'fails if there is no such title' do
529
529
  expect do
530
530
  expect(html).to have_title('No such title')
531
531
  end.to raise_error('expected "Just a title" to include "No such title"')
@@ -538,13 +538,13 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
538
538
  end
539
539
  end
540
540
 
541
- context "on a page or node" do
542
- it "passes if there is such a title" do
541
+ context 'on a page or node' do
542
+ it 'passes if there is such a title' do
543
543
  visit('/with_js')
544
544
  expect(page).to have_title('with_js')
545
545
  end
546
546
 
547
- it "fails if there is no such title" do
547
+ it 'fails if there is no such title' do
548
548
  visit('/with_js')
549
549
  expect do
550
550
  expect(page).to have_title('No such title')
@@ -558,14 +558,14 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
558
558
  end
559
559
 
560
560
  it 'waits if wait time is more than timeout' do
561
- @session.click_link("Change title")
561
+ @session.click_link('Change title')
562
562
  using_wait_time 0 do
563
563
  expect(@session).to have_title('changed title', wait: 2)
564
564
  end
565
565
  end
566
566
 
567
567
  it "doesn't wait if wait time is less than timeout" do
568
- @session.click_link("Change title")
568
+ @session.click_link('Change title')
569
569
  using_wait_time 3 do
570
570
  expect(@session).not_to have_title('changed title', wait: 0)
571
571
  end
@@ -573,23 +573,23 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
573
573
  end
574
574
  end
575
575
 
576
- it "supports compounding" do
577
- expect("<title>I compound</title>").to have_title('I dont compound').or have_title('I compound')
576
+ it 'supports compounding' do
577
+ expect('<title>I compound</title>').to have_title('I dont compound').or have_title('I compound')
578
578
  end
579
579
  end
580
580
 
581
- describe "have_current_path matcher" do
582
- it "gives proper description" do
583
- expect(have_current_path('http://www.example.com').description).to eq("have current path \"http://www.example.com\"")
581
+ describe 'have_current_path matcher' do
582
+ it 'gives proper description' do
583
+ expect(have_current_path('http://www.example.com').description).to eq('have current path "http://www.example.com"')
584
584
  end
585
585
 
586
- context "on a page or node" do
587
- it "passes if there is such a current path" do
586
+ context 'on a page or node' do
587
+ it 'passes if there is such a current path' do
588
588
  visit('/with_js')
589
589
  expect(page).to have_current_path('/with_js')
590
590
  end
591
591
 
592
- it "fails if there is no such current_path" do
592
+ it 'fails if there is no such current_path' do
593
593
  visit('/with_js')
594
594
  expect do
595
595
  expect(page).to have_current_path('/not_with_js')
@@ -603,14 +603,14 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
603
603
  end
604
604
 
605
605
  it 'waits if wait time is more than timeout' do
606
- @session.click_link("Change page")
606
+ @session.click_link('Change page')
607
607
  using_wait_time 0 do
608
608
  expect(@session).to have_current_path('/with_html', wait: 2)
609
609
  end
610
610
  end
611
611
 
612
612
  it "doesn't wait if wait time is less than timeout" do
613
- @session.click_link("Change page")
613
+ @session.click_link('Change page')
614
614
  using_wait_time 0 do
615
615
  expect(@session).not_to have_current_path('/with_html')
616
616
  end
@@ -618,240 +618,241 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
618
618
  end
619
619
  end
620
620
 
621
- it "supports compounding" do
621
+ it 'supports compounding' do
622
622
  visit('/with_html')
623
623
  expect(page).to have_current_path('/not_with_html').or have_current_path('/with_html')
624
624
  end
625
625
  end
626
626
 
627
- describe "have_button matcher" do
627
+ describe 'have_button matcher' do
628
628
  let(:html) { '<button>A button</button><input type="submit" value="Another button"/>' }
629
629
 
630
- it "gives proper description" do
631
- expect(have_button('A button').description).to eq("have visible button \"A button\"")
630
+ it 'gives proper description' do
631
+ expect(have_button('A button').description).to eq('have visible button "A button"')
632
632
  end
633
633
 
634
- it "passes if there is such a button" do
634
+ it 'passes if there is such a button' do
635
635
  expect(html).to have_button('A button')
636
636
  end
637
637
 
638
- it "fails if there is no such button" do
638
+ it 'fails if there is no such button' do
639
639
  expect do
640
640
  expect(html).to have_button('No such Button')
641
- end.to raise_error(/expected to find visible button "No such Button"/)
641
+ end.to raise_error(/expected to find button "No such Button"/)
642
642
  end
643
643
 
644
- it "supports compounding" do
644
+ it 'supports compounding' do
645
645
  expect(html).to have_button('Not this button').or have_button('A button')
646
646
  end
647
647
  end
648
648
 
649
- describe "have_field matcher" do
649
+ describe 'have_field matcher' do
650
650
  let(:html) { '<p><label>Text field<input type="text" value="some value"/></label></p>' }
651
651
 
652
- it "gives proper description" do
653
- expect(have_field('Text field').description).to eq("have visible field \"Text field\" that is not disabled")
652
+ it 'gives proper description' do
653
+ expect(have_field('Text field').description).to eq('have visible field "Text field" that is not disabled')
654
654
  end
655
655
 
656
- it "gives proper description for a given value" do
657
- expect(have_field('Text field', with: 'some value').description).to eq("have visible field \"Text field\" that is not disabled with value \"some value\"")
656
+ it 'gives proper description for a given value' do
657
+ expect(have_field('Text field', with: 'some value').description).to eq('have visible field "Text field" that is not disabled with value "some value"')
658
658
  end
659
659
 
660
- it "passes if there is such a field" do
660
+ it 'passes if there is such a field' do
661
661
  expect(html).to have_field('Text field')
662
662
  end
663
663
 
664
- it "passes if there is such a field with value" do
664
+ it 'passes if there is such a field with value' do
665
665
  expect(html).to have_field('Text field', with: 'some value')
666
666
  end
667
667
 
668
- it "fails if there is no such field" do
668
+ it 'fails if there is no such field' do
669
669
  expect do
670
670
  expect(html).to have_field('No such Field')
671
- end.to raise_error(/expected to find visible field "No such Field"/)
671
+ end.to raise_error(/expected to find field "No such Field"/)
672
672
  end
673
673
 
674
- it "fails if there is such field but with false value" do
674
+ it 'fails if there is such field but with false value' do
675
675
  expect do
676
676
  expect(html).to have_field('Text field', with: 'false value')
677
677
  end.to raise_error(/expected to find visible field "Text field"/)
678
678
  end
679
679
 
680
- it "treats a given value as a string" do
680
+ it 'treats a given value as a string' do
681
681
  class Foo
682
682
  def to_s
683
- "some value"
683
+ 'some value'
684
684
  end
685
685
  end
686
686
  expect(html).to have_field('Text field', with: Foo.new)
687
687
  end
688
688
 
689
- it "supports compounding" do
689
+ it 'supports compounding' do
690
690
  expect(html).to have_field('Not this one').or have_field('Text field')
691
691
  end
692
692
  end
693
693
 
694
- describe "have_checked_field matcher" do
694
+ describe 'have_checked_field matcher' do
695
695
  let(:html) do
696
696
  '<label>it is checked<input type="checkbox" checked="checked"/></label>
697
697
  <label>unchecked field<input type="checkbox"/></label>'
698
698
  end
699
699
 
700
- it "gives proper description" do
701
- expect(have_checked_field('it is checked').description).to eq("have visible field \"it is checked\" that is checked and not disabled")
700
+ it 'gives proper description' do
701
+ expect(have_checked_field('it is checked').description).to eq('have visible field "it is checked" that is checked and not disabled')
702
702
  end
703
703
 
704
- context "with should" do
705
- it "passes if there is such a field and it is checked" do
704
+ context 'with should' do
705
+ it 'passes if there is such a field and it is checked' do
706
706
  expect(html).to have_checked_field('it is checked')
707
707
  end
708
708
 
709
- it "fails if there is such a field but it is not checked" do
709
+ it 'fails if there is such a field but it is not checked' do
710
710
  expect do
711
711
  expect(html).to have_checked_field('unchecked field')
712
712
  end.to raise_error(/expected to find visible field "unchecked field"/)
713
713
  end
714
714
 
715
- it "fails if there is no such field" do
715
+ it 'fails if there is no such field' do
716
716
  expect do
717
717
  expect(html).to have_checked_field('no such field')
718
- end.to raise_error(/expected to find visible field "no such field"/)
718
+ end.to raise_error(/expected to find field "no such field"/)
719
719
  end
720
720
  end
721
721
 
722
- context "with should not" do
723
- it "fails if there is such a field and it is checked" do
722
+ context 'with should not' do
723
+ it 'fails if there is such a field and it is checked' do
724
724
  expect do
725
725
  expect(html).not_to have_checked_field('it is checked')
726
726
  end.to raise_error(/expected not to find visible field "it is checked"/)
727
727
  end
728
728
 
729
- it "passes if there is such a field but it is not checked" do
729
+ it 'passes if there is such a field but it is not checked' do
730
730
  expect(html).not_to have_checked_field('unchecked field')
731
731
  end
732
732
 
733
- it "passes if there is no such field" do
733
+ it 'passes if there is no such field' do
734
734
  expect(html).not_to have_checked_field('no such field')
735
735
  end
736
736
  end
737
737
 
738
- it "supports compounding" do
738
+ it 'supports compounding' do
739
739
  expect(html).to have_checked_field('not this one').or have_checked_field('it is checked')
740
740
  end
741
741
  end
742
742
 
743
- describe "have_unchecked_field matcher" do
743
+ describe 'have_unchecked_field matcher' do
744
744
  let(:html) do
745
745
  '<label>it is checked<input type="checkbox" checked="checked"/></label>
746
746
  <label>unchecked field<input type="checkbox"/></label>'
747
747
  end
748
748
 
749
- it "gives proper description" do
750
- expect(have_unchecked_field('unchecked field').description).to eq("have visible field \"unchecked field\" that is not checked and not disabled")
749
+ it 'gives proper description' do
750
+ expect(have_unchecked_field('unchecked field').description).to eq('have visible field "unchecked field" that is not checked and not disabled')
751
751
  end
752
752
 
753
- context "with should" do
754
- it "passes if there is such a field and it is not checked" do
753
+ context 'with should' do
754
+ it 'passes if there is such a field and it is not checked' do
755
755
  expect(html).to have_unchecked_field('unchecked field')
756
756
  end
757
757
 
758
- it "fails if there is such a field but it is checked" do
758
+ it 'fails if there is such a field but it is checked' do
759
759
  expect do
760
760
  expect(html).to have_unchecked_field('it is checked')
761
761
  end.to raise_error(/expected to find visible field "it is checked"/)
762
762
  end
763
763
 
764
- it "fails if there is no such field" do
764
+ it 'fails if there is no such field' do
765
765
  expect do
766
766
  expect(html).to have_unchecked_field('no such field')
767
- end.to raise_error(/expected to find visible field "no such field"/)
767
+ end.to raise_error(/expected to find field "no such field"/)
768
768
  end
769
769
  end
770
770
 
771
- context "with should not" do
772
- it "fails if there is such a field and it is not checked" do
771
+ context 'with should not' do
772
+ it 'fails if there is such a field and it is not checked' do
773
773
  expect do
774
774
  expect(html).not_to have_unchecked_field('unchecked field')
775
775
  end.to raise_error(/expected not to find visible field "unchecked field"/)
776
776
  end
777
777
 
778
- it "passes if there is such a field but it is checked" do
778
+ it 'passes if there is such a field but it is checked' do
779
779
  expect(html).not_to have_unchecked_field('it is checked')
780
780
  end
781
781
 
782
- it "passes if there is no such field" do
782
+ it 'passes if there is no such field' do
783
783
  expect(html).not_to have_unchecked_field('no such field')
784
784
  end
785
785
  end
786
786
 
787
- it "supports compounding" do
787
+ it 'supports compounding' do
788
788
  expect(html).to have_unchecked_field('it is checked').or have_unchecked_field('unchecked field')
789
789
  end
790
790
  end
791
791
 
792
- describe "have_select matcher" do
792
+ describe 'have_select matcher' do
793
793
  let(:html) { '<label>Select Box<select></select></label>' }
794
794
 
795
- it "gives proper description" do
796
- expect(have_select('Select Box').description).to eq("have visible select box \"Select Box\" that is not disabled")
795
+ it 'gives proper description' do
796
+ expect(have_select('Select Box').description).to eq('have visible select box "Select Box" that is not disabled')
797
797
  end
798
798
 
799
- it "gives proper description for a given selected value" do
799
+ it 'gives proper description for a given selected value' do
800
800
  expect(have_select('Select Box', selected: 'some value').description).to eq('have visible select box "Select Box" that is not disabled with "some value" selected')
801
801
  end
802
802
 
803
- it "passes if there is such a select" do
803
+ it 'passes if there is such a select' do
804
804
  expect(html).to have_select('Select Box')
805
805
  end
806
806
 
807
- it "fails if there is no such select" do
807
+ it 'fails if there is no such select' do
808
808
  expect do
809
809
  expect(html).to have_select('No such Select box')
810
- end.to raise_error(/expected to find visible select box "No such Select box"/)
810
+ end.to raise_error(/expected to find select box "No such Select box"/)
811
811
  end
812
812
 
813
- it "supports compounding" do
813
+ it 'supports compounding' do
814
814
  expect(html).to have_select('Not this one').or have_select('Select Box')
815
815
  end
816
816
  end
817
817
 
818
- describe "have_table matcher" do
818
+ describe 'have_table matcher' do
819
819
  let(:html) { '<table><caption>Lovely table</caption></table>' }
820
820
 
821
- it "gives proper description" do
822
- expect(have_table('Lovely table').description).to eq("have visible table \"Lovely table\"")
821
+ it 'gives proper description' do
822
+ expect(have_table('Lovely table').description).to eq('have visible table "Lovely table"')
823
+ expect(have_table('Lovely table', caption: 'my caption').description).to eq('have visible table "Lovely table" with caption "my caption"')
823
824
  end
824
825
 
825
- it "gives proper description when :visible option passed" do
826
- expect(have_table('Lovely table', visible: true).description).to eq("have visible table \"Lovely table\"")
827
- expect(have_table('Lovely table', visible: :hidden).description).to eq("have non-visible table \"Lovely table\"")
828
- expect(have_table('Lovely table', visible: :all).description).to eq("have table \"Lovely table\"")
829
- expect(have_table('Lovely table', visible: false).description).to eq("have table \"Lovely table\"")
826
+ it 'gives proper description when :visible option passed' do
827
+ expect(have_table('Lovely table', visible: true).description).to eq('have visible table "Lovely table"')
828
+ expect(have_table('Lovely table', visible: :hidden).description).to eq('have non-visible table "Lovely table"')
829
+ expect(have_table('Lovely table', visible: :all).description).to eq('have table "Lovely table"')
830
+ expect(have_table('Lovely table', visible: false).description).to eq('have table "Lovely table"')
830
831
  end
831
832
 
832
- it "passes if there is such a select" do
833
+ it 'passes if there is such a table' do
833
834
  expect(html).to have_table('Lovely table')
834
835
  end
835
836
 
836
- it "fails if there is no such select" do
837
+ it 'fails if there is no such table' do
837
838
  expect do
838
839
  expect(html).to have_table('No such Table')
839
- end.to raise_error(/expected to find visible table "No such Table"/)
840
+ end.to raise_error(/expected to find table "No such Table"/)
840
841
  end
841
842
 
842
- it "supports compounding" do
843
+ it 'supports compounding' do
843
844
  expect(html).to have_table('nope').or have_table('Lovely table')
844
845
  end
845
846
  end
846
847
 
847
- context "compounding timing" do
848
+ context 'compounding timing' do
848
849
  before do
849
850
  @session = session
850
851
  @session.visit('/with_js')
851
852
  @el = @session.find(:css, '#reload-me')
852
853
  end
853
854
 
854
- context "#and" do
855
+ context '#and' do
855
856
  it "should run 'concurrently'" do
856
857
  Capybara.using_wait_time(2) do
857
858
  matcher = have_text('this is not there').and have_text('neither is this')
@@ -874,7 +875,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
874
875
  end
875
876
  end
876
877
 
877
- it "should ignore :wait options" do
878
+ it 'should ignore :wait options' do
878
879
  @session.using_wait_time(2) do
879
880
  matcher = have_text('this is not there', wait: 5).and have_text('neither is this', wait: 6)
880
881
  expect(Benchmark.realtime do
@@ -885,7 +886,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
885
886
  end
886
887
  end
887
888
 
888
- it "should work on the session" do
889
+ it 'should work on the session' do
889
890
  @session.using_wait_time(2) do
890
891
  @session.click_link('reload-link')
891
892
  expect(@session).to have_selector(:css, 'h1', text: 'FooBar').and have_text('has been reloaded')
@@ -893,14 +894,14 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
893
894
  end
894
895
  end
895
896
 
896
- context "#and_then" do
897
- it "should run sequentially" do
897
+ context '#and_then' do
898
+ it 'should run sequentially' do
898
899
  @session.click_link('reload-link')
899
900
  expect(@el).to have_text('waiting to be reloaded').and_then have_text('has been reloaded')
900
901
  end
901
902
  end
902
903
 
903
- context "#or" do
904
+ context '#or' do
904
905
  it "should run 'concurrently'" do
905
906
  @session.using_wait_time(3) do
906
907
  expect(Benchmark.realtime do
@@ -909,7 +910,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
909
910
  end
910
911
  end
911
912
 
912
- it "should retry" do
913
+ it 'should retry' do
913
914
  @session.using_wait_time(3) do
914
915
  expect(Benchmark.realtime do
915
916
  expect do
@@ -919,7 +920,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
919
920
  end
920
921
  end
921
922
 
922
- it "should ignore :wait options" do
923
+ it 'should ignore :wait options' do
923
924
  @session.using_wait_time(2) do
924
925
  expect(Benchmark.realtime do
925
926
  expect do
@@ -929,7 +930,7 @@ RSpec.shared_examples Capybara::RSpecMatchers do |session, _mode|
929
930
  end
930
931
  end
931
932
 
932
- it "should work on the session" do
933
+ it 'should work on the session' do
933
934
  @session.using_wait_time(2) do
934
935
  @session.click_link('reload-link')
935
936
  expect(@session).to have_selector(:css, 'h1', text: 'Not on the page').or have_text('has been reloaded')