capybara 2.9.2 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +10 -1
  3. data/README.md +34 -27
  4. data/lib/capybara.rb +2 -2
  5. data/lib/capybara/node/actions.rb +3 -3
  6. data/lib/capybara/node/base.rb +2 -2
  7. data/lib/capybara/node/element.rb +1 -1
  8. data/lib/capybara/node/finders.rb +37 -32
  9. data/lib/capybara/node/matchers.rb +187 -171
  10. data/lib/capybara/queries/selector_query.rb +11 -14
  11. data/lib/capybara/rack_test/driver.rb +3 -3
  12. data/lib/capybara/rails.rb +1 -1
  13. data/lib/capybara/rspec/features.rb +1 -1
  14. data/lib/capybara/rspec/matchers.rb +31 -22
  15. data/lib/capybara/selector.rb +2 -2
  16. data/lib/capybara/selector/selector.rb +22 -0
  17. data/lib/capybara/session.rb +4 -4
  18. data/lib/capybara/spec/session/accept_alert_spec.rb +4 -4
  19. data/lib/capybara/spec/session/accept_confirm_spec.rb +1 -1
  20. data/lib/capybara/spec/session/accept_prompt_spec.rb +5 -5
  21. data/lib/capybara/spec/session/all_spec.rb +27 -27
  22. data/lib/capybara/spec/session/assert_current_path.rb +2 -2
  23. data/lib/capybara/spec/session/assert_selector.rb +28 -28
  24. data/lib/capybara/spec/session/assert_text.rb +20 -20
  25. data/lib/capybara/spec/session/assert_title.rb +2 -2
  26. data/lib/capybara/spec/session/attach_file_spec.rb +2 -2
  27. data/lib/capybara/spec/session/check_spec.rb +5 -5
  28. data/lib/capybara/spec/session/choose_spec.rb +4 -4
  29. data/lib/capybara/spec/session/click_button_spec.rb +18 -5
  30. data/lib/capybara/spec/session/click_link_or_button_spec.rb +6 -6
  31. data/lib/capybara/spec/session/click_link_spec.rb +13 -13
  32. data/lib/capybara/spec/session/current_url_spec.rb +2 -2
  33. data/lib/capybara/spec/session/dismiss_confirm_spec.rb +1 -1
  34. data/lib/capybara/spec/session/dismiss_prompt_spec.rb +1 -1
  35. data/lib/capybara/spec/session/element/matches_selector_spec.rb +15 -8
  36. data/lib/capybara/spec/session/evaluate_script_spec.rb +1 -1
  37. data/lib/capybara/spec/session/execute_script_spec.rb +2 -2
  38. data/lib/capybara/spec/session/fill_in_spec.rb +30 -30
  39. data/lib/capybara/spec/session/find_button_spec.rb +5 -5
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +2 -2
  41. data/lib/capybara/spec/session/find_field_spec.rb +11 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +2 -2
  43. data/lib/capybara/spec/session/find_spec.rb +52 -48
  44. data/lib/capybara/spec/session/first_spec.rb +9 -9
  45. data/lib/capybara/spec/session/go_back_spec.rb +1 -1
  46. data/lib/capybara/spec/session/go_forward_spec.rb +1 -1
  47. data/lib/capybara/spec/session/has_button_spec.rb +12 -12
  48. data/lib/capybara/spec/session/has_css_spec.rb +73 -73
  49. data/lib/capybara/spec/session/has_current_path_spec.rb +2 -2
  50. data/lib/capybara/spec/session/has_field_spec.rb +78 -68
  51. data/lib/capybara/spec/session/has_link_spec.rb +8 -8
  52. data/lib/capybara/spec/session/has_select_spec.rb +70 -61
  53. data/lib/capybara/spec/session/has_selector_spec.rb +28 -28
  54. data/lib/capybara/spec/session/has_text_spec.rb +6 -6
  55. data/lib/capybara/spec/session/has_title_spec.rb +2 -2
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +26 -26
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +3 -3
  59. data/lib/capybara/spec/session/node_spec.rb +15 -15
  60. data/lib/capybara/spec/session/reset_session_spec.rb +4 -4
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +3 -3
  63. data/lib/capybara/spec/session/screenshot_spec.rb +1 -1
  64. data/lib/capybara/spec/session/select_spec.rb +30 -30
  65. data/lib/capybara/spec/session/uncheck_spec.rb +2 -2
  66. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  67. data/lib/capybara/spec/session/visit_spec.rb +2 -2
  68. data/lib/capybara/spec/session/within_frame_spec.rb +2 -2
  69. data/lib/capybara/spec/session/within_spec.rb +6 -6
  70. data/lib/capybara/spec/spec_helper.rb +1 -1
  71. data/lib/capybara/spec/test_app.rb +1 -1
  72. data/lib/capybara/spec/views/form.erb +1 -0
  73. data/lib/capybara/version.rb +1 -1
  74. data/spec/basic_node_spec.rb +5 -5
  75. data/spec/capybara_spec.rb +1 -1
  76. data/spec/dsl_spec.rb +1 -1
  77. data/spec/rack_test_spec.rb +7 -7
  78. data/spec/rspec/matchers_spec.rb +6 -6
  79. data/spec/rspec_spec.rb +1 -1
  80. data/spec/selector_spec.rb +13 -0
  81. data/spec/selenium_firefox_spec.rb +1 -1
  82. data/spec/selenium_spec_chrome.rb +1 -1
  83. data/spec/shared_selenium_session.rb +10 -10
  84. metadata +2 -2
@@ -7,8 +7,9 @@ module Capybara
7
7
  VALID_KEYS = COUNT_KEYS + [:text, :id, :class, :visible, :exact, :match, :wait, :filter_set]
8
8
  VALID_MATCH = [:first, :smart, :prefer_exact, :one]
9
9
 
10
- def initialize(*args)
10
+ def initialize(*args, &filter_block)
11
11
  @options = if args.last.is_a?(Hash) then args.pop.dup else {} end
12
+ @filter_block = filter_block
12
13
 
13
14
  if args[0].is_a?(Symbol)
14
15
  @selector = Selector.all.fetch(args.shift) do |selector_type|
@@ -45,6 +46,7 @@ module Capybara
45
46
  @description << " with id #{options[:id]}" if options[:id]
46
47
  @description << " with classes #{Array(options[:class]).join(',')}]" if options[:class]
47
48
  @description << selector.description(options)
49
+ @description << " that also matches the custom filter block" if @filter_block
48
50
  @description
49
51
  end
50
52
 
@@ -59,7 +61,7 @@ module Capybara
59
61
  when :hidden then return false if node.visible?
60
62
  end
61
63
 
62
- query_filters.all? do |name, filter|
64
+ res = query_filters.all? do |name, filter|
63
65
  if options.has_key?(name)
64
66
  filter.matches?(node, options[name])
65
67
  elsif filter.default?
@@ -68,21 +70,16 @@ module Capybara
68
70
  true
69
71
  end
70
72
  end
73
+
74
+ res &&= @filter_block.call(node) unless @filter_block.nil?
75
+ res
71
76
  end
72
77
 
73
78
  def visible
74
- if options.has_key?(:visible)
75
- case @options[:visible]
76
- when true then :visible
77
- when false then :all
78
- else @options[:visible]
79
- end
80
- else
81
- if Capybara.ignore_hidden_elements
82
- :visible
83
- else
84
- :all
85
- end
79
+ case (vis = options.fetch(:visible){ @selector.default_visibility })
80
+ when true then :visible
81
+ when false then :all
82
+ else vis
86
83
  end
87
84
  end
88
85
 
@@ -7,9 +7,9 @@ require 'cgi'
7
7
 
8
8
  class Capybara::RackTest::Driver < Capybara::Driver::Base
9
9
  DEFAULT_OPTIONS = {
10
- :respect_data_method => false,
11
- :follow_redirects => true,
12
- :redirect_limit => 5
10
+ respect_data_method: false,
11
+ follow_redirects: true,
12
+ redirect_limit: 5
13
13
  }
14
14
  attr_reader :app, :options
15
15
 
@@ -16,5 +16,5 @@ Capybara.save_path = Rails.root.join('tmp/capybara')
16
16
 
17
17
  # Override default rack_test driver to respect data-method attributes.
18
18
  Capybara.register_driver :rack_test do |app|
19
- Capybara::RackTest::Driver.new(app, :respect_data_method => true)
19
+ Capybara::RackTest::Driver.new(app, respect_data_method: true)
20
20
  end
@@ -51,6 +51,6 @@ else
51
51
  end
52
52
 
53
53
  RSpec.configure do |config|
54
- config.include(Capybara::Features, :capybara_feature => true)
54
+ config.include(Capybara::Features, capybara_feature: true)
55
55
  end
56
56
  end
@@ -16,8 +16,9 @@ module Capybara
16
16
  class HaveSelector < Matcher
17
17
  attr_reader :failure_message, :failure_message_when_negated
18
18
 
19
- def initialize(*args)
19
+ def initialize(*args, &filter_block)
20
20
  @args = args
21
+ @filter_block = filter_block
21
22
  end
22
23
 
23
24
  def matches?(actual)
@@ -39,7 +40,7 @@ module Capybara
39
40
  end
40
41
 
41
42
  def query
42
- @query ||= Capybara::Queries::SelectorQuery.new(*@args)
43
+ @query ||= Capybara::Queries::SelectorQuery.new(*@args, &@filter_block)
43
44
  end
44
45
 
45
46
  # RSpec 2 compatibility:
@@ -221,8 +222,8 @@ module Capybara
221
222
  alias_method :failure_message_for_should_not, :failure_message_when_negated
222
223
  end
223
224
 
224
- def have_selector(*args)
225
- HaveSelector.new(*args)
225
+ def have_selector(*args, &optional_filter_block)
226
+ HaveSelector.new(*args, &optional_filter_block)
226
227
  end
227
228
 
228
229
  def match_selector(*args)
@@ -233,16 +234,16 @@ module Capybara
233
234
  ::RSpec::Matchers.define_negated_matcher :not_match_selector, :match_selector if defined?(::RSpec::Expectations::Version) && (Gem::Version.new(RSpec::Expectations::Version::STRING) >= Gem::Version.new('3.1'))
234
235
 
235
236
 
236
- def have_xpath(xpath, options={})
237
- HaveSelector.new(:xpath, xpath, options)
237
+ def have_xpath(xpath, options={}, &optional_filter_block)
238
+ HaveSelector.new(:xpath, xpath, options, &optional_filter_block)
238
239
  end
239
240
 
240
241
  def match_xpath(xpath, options={})
241
242
  MatchSelector.new(:xpath, xpath, options)
242
243
  end
243
244
 
244
- def have_css(css, options={})
245
- HaveSelector.new(:css, css, options)
245
+ def have_css(css, options={}, &optional_filter_block)
246
+ HaveSelector.new(:css, css, options, &optional_filter_block)
246
247
  end
247
248
 
248
249
  def match_css(css, options={})
@@ -262,32 +263,39 @@ module Capybara
262
263
  HaveCurrentPath.new(path, options)
263
264
  end
264
265
 
265
- def have_link(locator, options={})
266
- HaveSelector.new(:link, locator, options)
266
+ def have_link(locator=nil, options={}, &optional_filter_block)
267
+ locator, options = nil, locator if locator.is_a? Hash
268
+ HaveSelector.new(:link, locator, options, &optional_filter_block)
267
269
  end
268
270
 
269
- def have_button(locator, options={})
270
- HaveSelector.new(:button, locator, options)
271
+ def have_button(locator=nil, options={}, &optional_filter_block)
272
+ locator, options = nil, locator if locator.is_a? Hash
273
+ HaveSelector.new(:button, locator, options, &optional_filter_block)
271
274
  end
272
275
 
273
- def have_field(locator, options={})
274
- HaveSelector.new(:field, locator, options)
276
+ def have_field(locator=nil, options={}, &optional_filter_block)
277
+ locator, options = nil, locator if locator.is_a? Hash
278
+ HaveSelector.new(:field, locator, options, &optional_filter_block)
275
279
  end
276
280
 
277
- def have_checked_field(locator, options={})
278
- HaveSelector.new(:field, locator, options.merge(:checked => true))
281
+ def have_checked_field(locator=nil, options={}, &optional_filter_block)
282
+ locator, options = nil, locator if locator.is_a? Hash
283
+ HaveSelector.new(:field, locator, options.merge(checked: true), &optional_filter_block)
279
284
  end
280
285
 
281
- def have_unchecked_field(locator, options={})
282
- HaveSelector.new(:field, locator, options.merge(:unchecked => true))
286
+ def have_unchecked_field(locator=nil, options={}, &optional_filter_block)
287
+ locator, options = nil, locator if locator.is_a? Hash
288
+ HaveSelector.new(:field, locator, options.merge(unchecked: true), &optional_filter_block)
283
289
  end
284
290
 
285
- def have_select(locator, options={})
286
- HaveSelector.new(:select, locator, options)
291
+ def have_select(locator=nil, options={}, &optional_filter_block)
292
+ locator, options = nil, locator if locator.is_a? Hash
293
+ HaveSelector.new(:select, locator, options, &optional_filter_block)
287
294
  end
288
295
 
289
- def have_table(locator, options={})
290
- HaveSelector.new(:table, locator, options)
296
+ def have_table(locator=nil, options={}, &optional_filter_block)
297
+ locator, options = nil, locator if locator.is_a? Hash
298
+ HaveSelector.new(:table, locator, options, &optional_filter_block)
291
299
  end
292
300
 
293
301
  ##
@@ -299,5 +307,6 @@ module Capybara
299
307
  def become_closed(options = {})
300
308
  BecomeClosed.new(options)
301
309
  end
310
+
302
311
  end
303
312
  end
@@ -157,7 +157,7 @@ end
157
157
  #
158
158
  # Find buttons ( input [of type submit, reset, image, button] or button elements )
159
159
  #
160
- # @locator Matches the id, value, or title attributes, string content of a button, or the alt attribute of an image type button
160
+ # @locator Matches the id, value, or title attributes, string content of a button, or the alt attribute of an image type button or of a descendant image of a button
161
161
  #
162
162
  # @filter [String] :id Matches the id attribute
163
163
  # @filter [String] :title Matches the title attribute
@@ -177,7 +177,7 @@ Capybara.add_selector(:button) do
177
177
 
178
178
  input_btn_xpath = input_btn_xpath[locator_matches]
179
179
 
180
- btn_xpath = btn_xpath[locator_matches | XPath.string.n.is(locator)]
180
+ btn_xpath = btn_xpath[locator_matches | XPath.string.n.is(locator) | XPath.descendant(:img)[XPath.attr(:alt).is(locator)]]
181
181
 
182
182
  alt_matches = XPath.attr(:alt).is(locator)
183
183
  alt_matches |= XPath.attr(:'aria-label').is(locator) if Capybara.enable_aria_label
@@ -50,6 +50,7 @@ module Capybara
50
50
  @format = nil
51
51
  @expression = nil
52
52
  @expression_filters = []
53
+ @default_visibility = nil
53
54
  instance_eval(&block)
54
55
  end
55
56
 
@@ -186,6 +187,27 @@ module Capybara
186
187
  @filter_set.describe &block
187
188
  end
188
189
 
190
+ ##
191
+ #
192
+ # Set the default visibility mode that shouble be used if no visibile option is passed when using the selector.
193
+ # If not specified will default to the behavior indicated by Capybara.ignore_hidden_elements
194
+ #
195
+ # @param [Symbol] default_visibility Only find elements with the specified visibility:
196
+ # * :all - finds visible and invisible elements.
197
+ # * :hidden - only finds invisible elements.
198
+ # * :visible - only finds visible elements.
199
+ def visible(default_visibility)
200
+ @default_visibility = default_visibility
201
+ end
202
+
203
+ def default_visibility
204
+ if @default_visibility.nil?
205
+ Capybara.ignore_hidden_elements
206
+ else
207
+ @default_visibility
208
+ end
209
+ end
210
+
189
211
  private
190
212
 
191
213
  def locate_field(xpath, locator, options={})
@@ -20,7 +20,7 @@ module Capybara
20
20
  # +current_path, and so on. It also delegate a number of methods to a Capybara::Document, representing
21
21
  # the current HTML document. This allows interaction:
22
22
  #
23
- # session.fill_in('q', :with => 'Capybara')
23
+ # session.fill_in('q', with: 'Capybara')
24
24
  # session.click_button('Search')
25
25
  # expect(session).to have_content('Capybara')
26
26
  #
@@ -264,7 +264,7 @@ module Capybara
264
264
  # to the given element.
265
265
  #
266
266
  # within(:xpath, '//div[@id="delivery-address"]') do
267
- # fill_in('Street', :with => '12 Main Street')
267
+ # fill_in('Street', with: '12 Main Street')
268
268
  # end
269
269
  #
270
270
  # Just as with `find`, if multiple elements match the selector given to
@@ -275,13 +275,13 @@ module Capybara
275
275
  # assumed to be of the type set in Capybara.default_selector.
276
276
  #
277
277
  # within('div#delivery-address') do
278
- # fill_in('Street', :with => '12 Main Street')
278
+ # fill_in('Street', with: '12 Main Street')
279
279
  # end
280
280
  #
281
281
  # Note that a lot of uses of `within` can be replaced more succinctly with
282
282
  # chaining:
283
283
  #
284
- # find('div#delivery-address').fill_in('Street', :with => '12 Main Street')
284
+ # find('div#delivery-address').fill_in('Street', with: '12 Main Street')
285
285
  #
286
286
  # @overload within(*find_args)
287
287
  # @param (see Capybara::Node::Finders#all)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do
2
+ Capybara::SpecHelper.spec '#accept_alert', requires: [:modals] do
3
3
  before do
4
4
  @session.visit('/with_js')
5
5
  end
@@ -10,14 +10,14 @@ Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do
10
10
  end
11
11
  expect(@session).to have_xpath("//a[@id='open-alert' and @opened='true']")
12
12
  end
13
-
13
+
14
14
  it "should accept the alert if the text matches" do
15
15
  @session.accept_alert 'Alert opened' do
16
16
  @session.click_link('Open alert')
17
17
  end
18
18
  expect(@session).to have_xpath("//a[@id='open-alert' and @opened='true']")
19
19
  end
20
-
20
+
21
21
  it "should not accept the alert if the text doesnt match" do
22
22
  expect do
23
23
  @session.accept_alert 'Incorrect Text' do
@@ -47,7 +47,7 @@ Capybara::SpecHelper.spec '#accept_alert', :requires => [:modals] do
47
47
  end
48
48
  expect(message).to eq('Delayed alert opened')
49
49
  end
50
-
50
+
51
51
  it "should allow to adjust the delay" do
52
52
  @session.accept_alert wait: 4 do
53
53
  @session.click_link('Open slow alert')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec '#accept_confirm', :requires => [:modals] do
2
+ Capybara::SpecHelper.spec '#accept_confirm', requires: [:modals] do
3
3
  before do
4
4
  @session.visit('/with_js')
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- Capybara::SpecHelper.spec '#accept_prompt', :requires => [:modals] do
2
+ Capybara::SpecHelper.spec '#accept_prompt', requires: [:modals] do
3
3
  before do
4
4
  @session.visit('/with_js')
5
5
  end
@@ -17,21 +17,21 @@ Capybara::SpecHelper.spec '#accept_prompt', :requires => [:modals] do
17
17
  end
18
18
  expect(message).to eq('Prompt opened')
19
19
  end
20
-
20
+
21
21
  it "should accept the prompt with a response" do
22
22
  @session.accept_prompt with: 'the response' do
23
23
  @session.click_link('Open prompt')
24
24
  end
25
25
  expect(@session).to have_xpath("//a[@id='open-prompt' and @response='the response']")
26
26
  end
27
-
27
+
28
28
  it "should accept the prompt if the message matches" do
29
29
  @session.accept_prompt 'Prompt opened', with: 'matched' do
30
30
  @session.click_link('Open prompt')
31
31
  end
32
32
  expect(@session).to have_xpath("//a[@id='open-prompt' and @response='matched']")
33
33
  end
34
-
34
+
35
35
  it "should not accept the prompt if the message doesn't match" do
36
36
  expect do
37
37
  @session.accept_prompt 'Incorrect Text', with: 'not matched' do
@@ -39,7 +39,7 @@ Capybara::SpecHelper.spec '#accept_prompt', :requires => [:modals] do
39
39
  end
40
40
  end.to raise_error(Capybara::ModalNotFound)
41
41
  end
42
-
42
+
43
43
 
44
44
  it "should return the message presented" do
45
45
  message = @session.accept_prompt with: 'the response' do
@@ -22,7 +22,7 @@ Capybara::SpecHelper.spec "#all" do
22
22
  end
23
23
 
24
24
  it "should raise an error when given invalid options" do
25
- expect { @session.all('//p', :schmoo => "foo") }.to raise_error(ArgumentError)
25
+ expect { @session.all('//p', schmoo: "foo") }.to raise_error(ArgumentError)
26
26
  end
27
27
 
28
28
  context "with css selectors" do
@@ -53,11 +53,11 @@ Capybara::SpecHelper.spec "#all" do
53
53
 
54
54
  context "with visible filter" do
55
55
  it "should only find visible nodes when true" do
56
- expect(@session.all(:css, "a.simple", :visible => true).size).to eq(1)
56
+ expect(@session.all(:css, "a.simple", visible: true).size).to eq(1)
57
57
  end
58
58
 
59
59
  it "should find nodes regardless of whether they are invisible when false" do
60
- expect(@session.all(:css, "a.simple", :visible => false).size).to eq(2)
60
+ expect(@session.all(:css, "a.simple", visible: false).size).to eq(2)
61
61
  end
62
62
 
63
63
  it "should default to Capybara.ignore_hidden_elements" do
@@ -71,68 +71,68 @@ Capybara::SpecHelper.spec "#all" do
71
71
  context 'with element count filters' do
72
72
  context ':count' do
73
73
  it 'should succeed when the number of elements founds matches the expectation' do
74
- expect { @session.all(:css, 'h1, p', :count => 4) }.to_not raise_error
74
+ expect { @session.all(:css, 'h1, p', count: 4) }.to_not raise_error
75
75
  end
76
76
  it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
77
- expect { @session.all(:css, 'h1, p', :count => 5) }.to raise_error(Capybara::ExpectationNotMet)
77
+ expect { @session.all(:css, 'h1, p', count: 5) }.to raise_error(Capybara::ExpectationNotMet)
78
78
  end
79
79
  end
80
80
  context ':minimum' do
81
81
  it 'should succeed when the number of elements founds matches the expectation' do
82
- expect { @session.all(:css, 'h1, p', :minimum => 0) }.to_not raise_error
82
+ expect { @session.all(:css, 'h1, p', minimum: 0) }.to_not raise_error
83
83
  end
84
84
  it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
85
- expect { @session.all(:css, 'h1, p', :minimum => 5) }.to raise_error(Capybara::ExpectationNotMet)
85
+ expect { @session.all(:css, 'h1, p', minimum: 5) }.to raise_error(Capybara::ExpectationNotMet)
86
86
  end
87
87
  end
88
88
  context ':maximum' do
89
89
  it 'should succeed when the number of elements founds matches the expectation' do
90
- expect { @session.all(:css, 'h1, p', :maximum => 4) }.to_not raise_error
90
+ expect { @session.all(:css, 'h1, p', maximum: 4) }.to_not raise_error
91
91
  end
92
92
  it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
93
- expect { @session.all(:css, 'h1, p', :maximum => 0) }.to raise_error(Capybara::ExpectationNotMet)
93
+ expect { @session.all(:css, 'h1, p', maximum: 0) }.to raise_error(Capybara::ExpectationNotMet)
94
94
  end
95
95
  end
96
96
  context ':between' do
97
97
  it 'should succeed when the number of elements founds matches the expectation' do
98
- expect { @session.all(:css, 'h1, p', :between => 2..7) }.to_not raise_error
98
+ expect { @session.all(:css, 'h1, p', between: 2..7) }.to_not raise_error
99
99
  end
100
100
  it 'should raise ExpectationNotMet when the number of elements founds does not match the expectation' do
101
- expect { @session.all(:css, 'h1, p', :between => 0..3) }.to raise_error(Capybara::ExpectationNotMet)
101
+ expect { @session.all(:css, 'h1, p', between: 0..3) }.to raise_error(Capybara::ExpectationNotMet)
102
102
  end
103
103
  end
104
104
 
105
105
  context 'with multiple count filters' do
106
106
  it 'ignores other filters when :count is specified' do
107
- o = {:count => 4,
108
- :minimum => 5,
109
- :maximum => 0,
110
- :between => 0..3}
107
+ o = {count: 4,
108
+ minimum: 5,
109
+ maximum: 0,
110
+ between: 0..3}
111
111
  expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
112
112
  end
113
113
  context 'with no :count expectation' do
114
114
  it 'fails if :minimum is not met' do
115
- o = {:minimum => 5,
116
- :maximum => 4,
117
- :between => 2..7}
115
+ o = {minimum: 5,
116
+ maximum: 4,
117
+ between: 2..7}
118
118
  expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
119
119
  end
120
120
  it 'fails if :maximum is not met' do
121
- o = {:minimum => 0,
122
- :maximum => 0,
123
- :between => 2..7}
121
+ o = {minimum: 0,
122
+ maximum: 0,
123
+ between: 2..7}
124
124
  expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
125
125
  end
126
126
  it 'fails if :between is not met' do
127
- o = {:minimum => 0,
128
- :maximum => 4,
129
- :between => 0..3}
127
+ o = {minimum: 0,
128
+ maximum: 4,
129
+ between: 0..3}
130
130
  expect { @session.all(:css, 'h1, p', o) }.to raise_error(Capybara::ExpectationNotMet)
131
131
  end
132
132
  it 'succeeds if all combineable expectations are met' do
133
- o = {:minimum => 0,
134
- :maximum => 4,
135
- :between => 2..7}
133
+ o = {minimum: 0,
134
+ maximum: 4,
135
+ between: 2..7}
136
136
  expect { @session.all(:css, 'h1, p', o) }.to_not raise_error
137
137
  end
138
138
  end