capybara 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,101 +1,101 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Capybara::SpecHelper.spec "#choose" do
3
+ Capybara::SpecHelper.spec '#choose' do
4
4
  before do
5
5
  @session.visit('/form')
6
6
  end
7
7
 
8
- it "should choose a radio button by id" do
9
- @session.choose("gender_male")
8
+ it 'should choose a radio button by id' do
9
+ @session.choose('gender_male')
10
10
  @session.click_button('awesome')
11
11
  expect(extract_results(@session)['gender']).to eq('male')
12
12
  end
13
13
 
14
- it "should choose a radio button by label" do
15
- @session.choose("Both")
14
+ it 'should choose a radio button by label' do
15
+ @session.choose('Both')
16
16
  @session.click_button('awesome')
17
17
  expect(extract_results(@session)['gender']).to eq('both')
18
18
  end
19
19
 
20
- it "should work without a locator string" do
21
- @session.choose(id: "gender_male")
20
+ it 'should work without a locator string' do
21
+ @session.choose(id: 'gender_male')
22
22
  @session.click_button('awesome')
23
23
  expect(extract_results(@session)['gender']).to eq('male')
24
24
  end
25
25
 
26
- it "casts to string" do
27
- @session.choose("Both")
26
+ it 'casts to string' do
27
+ @session.choose('Both')
28
28
  @session.click_button(:awesome)
29
29
  expect(extract_results(@session)['gender']).to eq('both')
30
30
  end
31
31
 
32
32
  context "with a locator that doesn't exist" do
33
- it "should raise an error" do
34
- msg = "Unable to find visible radio button \"does not exist\" that is not disabled"
33
+ it 'should raise an error' do
34
+ msg = 'Unable to find radio button "does not exist"'
35
35
  expect do
36
36
  @session.choose('does not exist')
37
37
  end.to raise_error(Capybara::ElementNotFound, msg)
38
38
  end
39
39
  end
40
40
 
41
- context "with a disabled radio button" do
42
- it "should raise an error" do
41
+ context 'with a disabled radio button' do
42
+ it 'should raise an error' do
43
43
  expect do
44
44
  @session.choose('Disabled Radio')
45
45
  end.to raise_error(Capybara::ElementNotFound)
46
46
  end
47
47
  end
48
48
 
49
- context "with :exact option" do
50
- it "should accept partial matches when false" do
51
- @session.choose("Mal", exact: false)
49
+ context 'with :exact option' do
50
+ it 'should accept partial matches when false' do
51
+ @session.choose('Mal', exact: false)
52
52
  @session.click_button('awesome')
53
53
  expect(extract_results(@session)['gender']).to eq('male')
54
54
  end
55
55
 
56
- it "should not accept partial matches when true" do
56
+ it 'should not accept partial matches when true' do
57
57
  expect do
58
- @session.choose("Mal", exact: true)
58
+ @session.choose('Mal', exact: true)
59
59
  end.to raise_error(Capybara::ElementNotFound)
60
60
  end
61
61
  end
62
62
 
63
- context "with `option` option" do
64
- it "can check radio buttons by their value" do
65
- @session.choose('form[gender]', option: "male")
63
+ context 'with `option` option' do
64
+ it 'can check radio buttons by their value' do
65
+ @session.choose('form[gender]', option: 'male')
66
66
  @session.click_button('awesome')
67
- expect(extract_results(@session)['gender']).to eq("male")
67
+ expect(extract_results(@session)['gender']).to eq('male')
68
68
  end
69
69
 
70
- it "should raise an error if option not found" do
70
+ it 'should raise an error if option not found' do
71
71
  expect do
72
- @session.choose('form[gender]', option: "hermaphrodite")
72
+ @session.choose('form[gender]', option: 'hermaphrodite')
73
73
  end.to raise_error(Capybara::ElementNotFound)
74
74
  end
75
75
  end
76
76
 
77
- context "with hidden radio buttons" do
78
- context "with Capybara.automatic_label_click == true" do
77
+ context 'with hidden radio buttons' do
78
+ context 'with Capybara.automatic_label_click == true' do
79
79
  around do |spec|
80
80
  old_click_label, Capybara.automatic_label_click = Capybara.automatic_label_click, true
81
81
  spec.run
82
82
  Capybara.automatic_label_click = old_click_label
83
83
  end
84
84
 
85
- it "should select by clicking the link if available" do
86
- @session.choose("party_democrat")
85
+ it 'should select by clicking the link if available' do
86
+ @session.choose('party_democrat')
87
87
  @session.click_button('awesome')
88
88
  expect(extract_results(@session)['party']).to eq('democrat')
89
89
  end
90
90
 
91
- it "should raise error if not allowed to click label" do
92
- expect { @session.choose("party_democrat", allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, 'Unable to find visible radio button "party_democrat" that is not disabled')
91
+ it 'should raise error if not allowed to click label' do
92
+ expect { @session.choose('party_democrat', allow_label_click: false) }.to raise_error(Capybara::ElementNotFound, 'Unable to find visible radio button "party_democrat"')
93
93
  end
94
94
  end
95
95
  end
96
96
 
97
- it "should return the chosen radio button" do
97
+ it 'should return the chosen radio button' do
98
98
  el = @session.find(:radio_button, 'gender_male')
99
- expect(@session.choose("gender_male")).to eq el
99
+ expect(@session.choose('gender_male')).to eq el
100
100
  end
101
101
  end
@@ -5,102 +5,102 @@ Capybara::SpecHelper.spec '#click_button' do
5
5
  @session.visit('/form')
6
6
  end
7
7
 
8
- it "should wait for asynchronous load", requires: [:js] do
8
+ it 'should wait for asynchronous load', requires: [:js] do
9
9
  @session.visit('/with_js')
10
10
  @session.click_link('Click me')
11
11
  @session.click_button('New Here')
12
12
  end
13
13
 
14
- it "casts to string" do
14
+ it 'casts to string' do
15
15
  @session.click_button(:'Relative Action')
16
16
  expect(extract_results(@session)['relative']).to eq('Relative Action')
17
17
  expect(@session.current_path).to eq('/relative')
18
18
  end
19
19
 
20
- context "with multiple values with the same name" do
21
- it "should use the latest given value" do
20
+ context 'with multiple values with the same name' do
21
+ it 'should use the latest given value' do
22
22
  @session.check('Terms of Use')
23
23
  @session.click_button('awesome')
24
24
  expect(extract_results(@session)['terms_of_use']).to eq('1')
25
25
  end
26
26
  end
27
27
 
28
- context "with a form that has a relative url as an action" do
29
- it "should post to the correct url" do
28
+ context 'with a form that has a relative url as an action' do
29
+ it 'should post to the correct url' do
30
30
  @session.click_button('Relative Action')
31
31
  expect(extract_results(@session)['relative']).to eq('Relative Action')
32
32
  expect(@session.current_path).to eq('/relative')
33
33
  end
34
34
  end
35
35
 
36
- context "with a form that has no action specified" do
37
- it "should post to the correct url" do
36
+ context 'with a form that has no action specified' do
37
+ it 'should post to the correct url' do
38
38
  @session.click_button('No Action')
39
39
  expect(extract_results(@session)['no_action']).to eq('No Action')
40
40
  expect(@session.current_path).to eq('/form')
41
41
  end
42
42
  end
43
43
 
44
- context "with value given on a submit button" do
45
- context "on a form with HTML5 fields" do
44
+ context 'with value given on a submit button' do
45
+ context 'on a form with HTML5 fields' do
46
46
  before do
47
47
  @session.click_button('html5_submit')
48
48
  @results = extract_results(@session)
49
49
  end
50
50
 
51
- it "should serialise and submit search fields" do
51
+ it 'should serialise and submit search fields' do
52
52
  expect(@results['html5_search']).to eq('what are you looking for')
53
53
  end
54
54
 
55
- it "should serialise and submit email fields" do
55
+ it 'should serialise and submit email fields' do
56
56
  expect(@results['html5_email']).to eq('person@email.com')
57
57
  end
58
58
 
59
- it "should serialise and submit url fields" do
59
+ it 'should serialise and submit url fields' do
60
60
  expect(@results['html5_url']).to eq('http://www.example.com')
61
61
  end
62
62
 
63
- it "should serialise and submit tel fields" do
63
+ it 'should serialise and submit tel fields' do
64
64
  expect(@results['html5_tel']).to eq('911')
65
65
  end
66
66
 
67
- it "should serialise and submit color fields" do
67
+ it 'should serialise and submit color fields' do
68
68
  expect(@results['html5_color'].upcase).to eq('#FFFFFF')
69
69
  end
70
70
  end
71
71
 
72
- context "on an HTML4 form" do
72
+ context 'on an HTML4 form' do
73
73
  before do
74
74
  @session.click_button('awesome')
75
75
  @results = extract_results(@session)
76
76
  end
77
77
 
78
- it "should serialize and submit text fields" do
78
+ it 'should serialize and submit text fields' do
79
79
  expect(@results['first_name']).to eq('John')
80
80
  end
81
81
 
82
- it "should escape fields when submitting" do
82
+ it 'should escape fields when submitting' do
83
83
  expect(@results['phone']).to eq('+1 555 7021')
84
84
  end
85
85
 
86
- it "should serialize and submit password fields" do
86
+ it 'should serialize and submit password fields' do
87
87
  expect(@results['password']).to eq('seeekrit')
88
88
  end
89
89
 
90
- it "should serialize and submit hidden fields" do
90
+ it 'should serialize and submit hidden fields' do
91
91
  expect(@results['token']).to eq('12345')
92
92
  end
93
93
 
94
- it "should not serialize fields from other forms" do
94
+ it 'should not serialize fields from other forms' do
95
95
  expect(@results['middle_name']).to be_nil
96
96
  end
97
97
 
98
- it "should submit the button that was clicked, but not other buttons" do
98
+ it 'should submit the button that was clicked, but not other buttons' do
99
99
  expect(@results['awesome']).to eq('awesome')
100
100
  expect(@results['crappy']).to be_nil
101
101
  end
102
102
 
103
- it "should serialize radio buttons" do
103
+ it 'should serialize radio buttons' do
104
104
  expect(@results['gender']).to eq('female')
105
105
  end
106
106
 
@@ -108,7 +108,7 @@ Capybara::SpecHelper.spec '#click_button' do
108
108
  expect(@results['valueless_radio']).to eq('on')
109
109
  end
110
110
 
111
- it "should serialize check boxes" do
111
+ it 'should serialize check boxes' do
112
112
  expect(@results['pets']).to include('dog', 'hamster')
113
113
  expect(@results['pets']).not_to include('cat')
114
114
  end
@@ -117,31 +117,31 @@ Capybara::SpecHelper.spec '#click_button' do
117
117
  expect(@results['valueless_checkbox']).to eq('on')
118
118
  end
119
119
 
120
- it "should serialize text areas" do
120
+ it 'should serialize text areas' do
121
121
  expect(@results['description']).to eq('Descriptive text goes here')
122
122
  end
123
123
 
124
- it "should serialize select tag with values" do
124
+ it 'should serialize select tag with values' do
125
125
  expect(@results['locale']).to eq('en')
126
126
  end
127
127
 
128
- it "should serialize select tag without values" do
128
+ it 'should serialize select tag without values' do
129
129
  expect(@results['region']).to eq('Norway')
130
130
  end
131
131
 
132
- it "should serialize first option for select tag with no selection" do
132
+ it 'should serialize first option for select tag with no selection' do
133
133
  expect(@results['city']).to eq('London')
134
134
  end
135
135
 
136
- it "should not serialize a select tag without options" do
136
+ it 'should not serialize a select tag without options' do
137
137
  expect(@results['tendency']).to be_nil
138
138
  end
139
139
 
140
- it "should convert lf to cr/lf in submitted textareas" do
140
+ it 'should convert lf to cr/lf in submitted textareas' do
141
141
  expect(@results['newline']).to eq("\r\nNew line after and before textarea tag\r\n")
142
142
  end
143
143
 
144
- it "should not submit disabled fields" do
144
+ it 'should not submit disabled fields' do
145
145
  expect(@results['disabled_text_field']).to be_nil
146
146
  expect(@results['disabled_textarea']).to be_nil
147
147
  expect(@results['disabled_checkbox']).to be_nil
@@ -152,57 +152,57 @@ Capybara::SpecHelper.spec '#click_button' do
152
152
  end
153
153
  end
154
154
 
155
- context "input type=submit button" do
156
- it "should submit by button id" do
155
+ context 'input type=submit button' do
156
+ it 'should submit by button id' do
157
157
  @session.click_button('awe123')
158
158
  expect(extract_results(@session)['first_name']).to eq('John')
159
159
  end
160
160
 
161
- it "should submit by button title" do
161
+ it 'should submit by button title' do
162
162
  @session.click_button('What an Awesome Button')
163
163
  expect(extract_results(@session)['first_name']).to eq('John')
164
164
  end
165
165
 
166
- it "should submit by partial title", :exact_false do
166
+ it 'should submit by partial title', :exact_false do
167
167
  @session.click_button('What an Awesome')
168
168
  expect(extract_results(@session)['first_name']).to eq('John')
169
169
  end
170
170
  end
171
171
 
172
- context "with fields associated with the form using the form attribute", requires: [:form_attribute] do
172
+ context 'with fields associated with the form using the form attribute', requires: [:form_attribute] do
173
173
  before do
174
174
  @session.click_button('submit_form1')
175
175
  @results = extract_results(@session)
176
176
  end
177
177
 
178
- it "should serialize and submit text fields" do
178
+ it 'should serialize and submit text fields' do
179
179
  expect(@results['outside_input']).to eq('outside_input')
180
180
  end
181
181
 
182
- it "should serialize text areas" do
182
+ it 'should serialize text areas' do
183
183
  expect(@results['outside_textarea']).to eq('Some text here')
184
184
  end
185
185
 
186
- it "should serialize select tags" do
186
+ it 'should serialize select tags' do
187
187
  expect(@results['outside_select']).to eq('Ruby')
188
188
  end
189
189
 
190
- it "should not serliaze fields associated with a different form" do
190
+ it 'should not serliaze fields associated with a different form' do
191
191
  expect(@results['for_form2']).to be_nil
192
192
  end
193
193
  end
194
194
 
195
- context "with submit button outside the form defined by <button> tag", requires: [:form_attribute] do
195
+ context 'with submit button outside the form defined by <button> tag', requires: [:form_attribute] do
196
196
  before do
197
197
  @session.click_button('outside_button')
198
198
  @results = extract_results(@session)
199
199
  end
200
200
 
201
- it "should submit the associated form" do
201
+ it 'should submit the associated form' do
202
202
  expect(@results['which_form']).to eq('form2')
203
203
  end
204
204
 
205
- it "should submit the button that was clicked, but not other buttons" do
205
+ it 'should submit the button that was clicked, but not other buttons' do
206
206
  expect(@results['outside_button']).to eq('outside_button')
207
207
  expect(@results['unused']).to be_nil
208
208
  end
@@ -214,91 +214,91 @@ Capybara::SpecHelper.spec '#click_button' do
214
214
  @results = extract_results(@session)
215
215
  end
216
216
 
217
- it "should submit the associated form" do
217
+ it 'should submit the associated form' do
218
218
  expect(@results['which_form']).to eq('form1')
219
219
  end
220
220
 
221
- it "should submit the button that was clicked, but not other buttons" do
221
+ it 'should submit the button that was clicked, but not other buttons' do
222
222
  expect(@results['outside_submit']).to eq('outside_submit')
223
223
  expect(@results['submit_form1']).to be_nil
224
224
  end
225
225
  end
226
226
 
227
- context "with submit button for form1 located within form2", requires: [:form_attribute] do
228
- it "should submit the form associated with the button" do
227
+ context 'with submit button for form1 located within form2', requires: [:form_attribute] do
228
+ it 'should submit the form associated with the button' do
229
229
  @session.click_button('other_form_button')
230
- expect(extract_results(@session)['which_form']).to eq("form1")
230
+ expect(extract_results(@session)['which_form']).to eq('form1')
231
231
  end
232
232
  end
233
233
 
234
- context "with submit button not associated with any form" do
235
- it "should not error when clicked" do
234
+ context 'with submit button not associated with any form' do
235
+ it 'should not error when clicked' do
236
236
  expect { @session.click_button('no_form_button') }.not_to raise_error
237
237
  end
238
238
  end
239
239
 
240
- context "with alt given on an image button" do
241
- it "should submit the associated form" do
240
+ context 'with alt given on an image button' do
241
+ it 'should submit the associated form' do
242
242
  @session.click_button('oh hai thar')
243
243
  expect(extract_results(@session)['first_name']).to eq('John')
244
244
  end
245
245
 
246
- it "should work with partial matches", :exact_false do
246
+ it 'should work with partial matches', :exact_false do
247
247
  @session.click_button('hai')
248
248
  expect(extract_results(@session)['first_name']).to eq('John')
249
249
  end
250
250
  end
251
251
 
252
- context "with value given on an image button" do
253
- it "should submit the associated form" do
252
+ context 'with value given on an image button' do
253
+ it 'should submit the associated form' do
254
254
  @session.click_button('okay')
255
255
  expect(extract_results(@session)['first_name']).to eq('John')
256
256
  end
257
257
 
258
- it "should work with partial matches", :exact_false do
258
+ it 'should work with partial matches', :exact_false do
259
259
  @session.click_button('kay')
260
260
  expect(extract_results(@session)['first_name']).to eq('John')
261
261
  end
262
262
  end
263
263
 
264
- context "with id given on an image button" do
265
- it "should submit the associated form" do
264
+ context 'with id given on an image button' do
265
+ it 'should submit the associated form' do
266
266
  @session.click_button('okay556')
267
267
  expect(extract_results(@session)['first_name']).to eq('John')
268
268
  end
269
269
  end
270
270
 
271
- context "with title given on an image button" do
272
- it "should submit the associated form" do
271
+ context 'with title given on an image button' do
272
+ it 'should submit the associated form' do
273
273
  @session.click_button('Okay 556 Image')
274
274
  expect(extract_results(@session)['first_name']).to eq('John')
275
275
  end
276
276
 
277
- it "should work with partial matches", :exact_false do
277
+ it 'should work with partial matches', :exact_false do
278
278
  @session.click_button('Okay 556')
279
279
  expect(extract_results(@session)['first_name']).to eq('John')
280
280
  end
281
281
  end
282
282
 
283
- context "with text given on a button defined by <button> tag" do
284
- it "should submit the associated form" do
283
+ context 'with text given on a button defined by <button> tag' do
284
+ it 'should submit the associated form' do
285
285
  @session.click_button('Click me!')
286
286
  expect(extract_results(@session)['first_name']).to eq('John')
287
287
  end
288
288
 
289
- it "should work with partial matches", :exact_false do
289
+ it 'should work with partial matches', :exact_false do
290
290
  @session.click_button('Click')
291
291
  expect(extract_results(@session)['first_name']).to eq('John')
292
292
  end
293
293
  end
294
294
 
295
- context "with id given on a button defined by <button> tag" do
296
- it "should submit the associated form" do
295
+ context 'with id given on a button defined by <button> tag' do
296
+ it 'should submit the associated form' do
297
297
  @session.click_button('click_me_123')
298
298
  expect(extract_results(@session)['first_name']).to eq('John')
299
299
  end
300
300
 
301
- it "should serialize and send GET forms" do
301
+ it 'should serialize and send GET forms' do
302
302
  @session.visit('/form')
303
303
  @session.click_button('med')
304
304
  @results = extract_results(@session)
@@ -307,53 +307,53 @@ Capybara::SpecHelper.spec '#click_button' do
307
307
  end
308
308
  end
309
309
 
310
- context "with value given on a button defined by <button> tag" do
311
- it "should submit the associated form" do
310
+ context 'with value given on a button defined by <button> tag' do
311
+ it 'should submit the associated form' do
312
312
  @session.click_button('click_me')
313
313
  expect(extract_results(@session)['first_name']).to eq('John')
314
314
  end
315
315
 
316
- it "should work with partial matches", :exact_false do
316
+ it 'should work with partial matches', :exact_false do
317
317
  @session.click_button('ck_me')
318
318
  expect(extract_results(@session)['first_name']).to eq('John')
319
319
  end
320
320
  end
321
321
 
322
- context "with title given on a button defined by <button> tag" do
323
- it "should submit the associated form" do
322
+ context 'with title given on a button defined by <button> tag' do
323
+ it 'should submit the associated form' do
324
324
  @session.click_button('Click Title button')
325
325
  expect(extract_results(@session)['first_name']).to eq('John')
326
326
  end
327
327
 
328
- it "should work with partial matches", :exact_false do
328
+ it 'should work with partial matches', :exact_false do
329
329
  @session.click_button('Click Title')
330
330
  expect(extract_results(@session)['first_name']).to eq('John')
331
331
  end
332
332
  end
333
333
 
334
- context "with descendant image alt given on a button defined by <button> tag" do
335
- it "should submit the associated form" do
334
+ context 'with descendant image alt given on a button defined by <button> tag' do
335
+ it 'should submit the associated form' do
336
336
  @session.click_button('A horse eating hay')
337
337
  expect(extract_results(@session)['first_name']).to eq('John')
338
338
  end
339
339
 
340
- it "should work with partial matches", :exact_false do
340
+ it 'should work with partial matches', :exact_false do
341
341
  @session.click_button('se eating h')
342
342
  expect(extract_results(@session)['first_name']).to eq('John')
343
343
  end
344
344
  end
345
345
 
346
346
  context "with a locator that doesn't exist" do
347
- it "should raise an error" do
348
- msg = "Unable to find visible button \"does not exist\""
347
+ it 'should raise an error' do
348
+ msg = 'Unable to find button "does not exist"'
349
349
  expect do
350
350
  @session.click_button('does not exist')
351
351
  end.to raise_error(Capybara::ElementNotFound, msg)
352
352
  end
353
353
  end
354
354
 
355
- context "with formaction attribute on button" do
356
- it "should submit to the formaction attribute" do
355
+ context 'with formaction attribute on button' do
356
+ it 'should submit to the formaction attribute' do
357
357
  @session.click_button('Formaction button')
358
358
  @results = extract_results(@session)
359
359
  expect(@session.current_path).to eq '/form'
@@ -361,8 +361,8 @@ Capybara::SpecHelper.spec '#click_button' do
361
361
  end
362
362
  end
363
363
 
364
- context "with formmethod attribute on button" do
365
- it "should submit to the formethod attribute" do
364
+ context 'with formmethod attribute on button' do
365
+ it 'should submit to the formethod attribute' do
366
366
  @session.click_button('Formmethod button')
367
367
  @results = extract_results(@session)
368
368
  expect(@session.current_path).to eq '/form/get'
@@ -370,19 +370,19 @@ Capybara::SpecHelper.spec '#click_button' do
370
370
  end
371
371
  end
372
372
 
373
- it "should serialize and send valueless buttons that were clicked" do
373
+ it 'should serialize and send valueless buttons that were clicked' do
374
374
  @session.click_button('No Value!')
375
375
  @results = extract_results(@session)
376
376
  expect(@results['no_value']).not_to be_nil
377
377
  end
378
378
 
379
- it "should not send image buttons that were not clicked" do
379
+ it 'should not send image buttons that were not clicked' do
380
380
  @session.click_button('Click me!')
381
381
  @results = extract_results(@session)
382
382
  expect(@results['okay']).to be_nil
383
383
  end
384
384
 
385
- it "should serialize and send GET forms" do
385
+ it 'should serialize and send GET forms' do
386
386
  @session.visit('/form')
387
387
  @session.click_button('med')
388
388
  @results = extract_results(@session)
@@ -390,41 +390,41 @@ Capybara::SpecHelper.spec '#click_button' do
390
390
  expect(@results['foo']).to be_nil
391
391
  end
392
392
 
393
- it "should follow redirects" do
393
+ it 'should follow redirects' do
394
394
  @session.click_button('Go FAR')
395
395
  expect(@session).to have_content('You landed')
396
396
  expect(@session.current_url).to match(%r{/landed$})
397
397
  end
398
398
 
399
- it "should follow temporary redirects that maintain method" do
399
+ it 'should follow temporary redirects that maintain method' do
400
400
  @session.click_button('Go 307')
401
401
  expect(@session).to have_content('You post landed: TWTW')
402
402
  end
403
403
 
404
- it "should follow permanent redirects that maintain method" do
404
+ it 'should follow permanent redirects that maintain method' do
405
405
  @session.click_button('Go 308')
406
406
  expect(@session).to have_content('You post landed: TWTW')
407
407
  end
408
408
 
409
- it "should post pack to the same URL when no action given" do
409
+ it 'should post pack to the same URL when no action given' do
410
410
  @session.visit('/postback')
411
411
  @session.click_button('With no action')
412
412
  expect(@session).to have_content('Postback')
413
413
  end
414
414
 
415
- it "should post pack to the same URL when blank action given" do
415
+ it 'should post pack to the same URL when blank action given' do
416
416
  @session.visit('/postback')
417
417
  @session.click_button('With blank action')
418
418
  expect(@session).to have_content('Postback')
419
419
  end
420
420
 
421
- it "ignores disabled buttons" do
421
+ it 'ignores disabled buttons' do
422
422
  expect do
423
423
  @session.click_button('Disabled button')
424
424
  end.to raise_error(Capybara::ElementNotFound)
425
425
  end
426
426
 
427
- it "should encode complex field names, like array[][value]" do
427
+ it 'should encode complex field names, like array[][value]' do
428
428
  @session.visit('/form')
429
429
  @session.fill_in('address1_city', with: 'Paris')
430
430
  @session.fill_in('address1_street', with: 'CDG')
@@ -432,27 +432,27 @@ Capybara::SpecHelper.spec '#click_button' do
432
432
  @session.fill_in('address2_city', with: 'Mikolaiv')
433
433
  @session.fill_in('address2_street', with: 'PGS')
434
434
 
435
- @session.click_button "awesome"
435
+ @session.click_button 'awesome'
436
436
 
437
- addresses = extract_results(@session)["addresses"]
437
+ addresses = extract_results(@session)['addresses']
438
438
  expect(addresses.size).to eq(2)
439
439
 
440
- expect(addresses[0]["street"]).to eq('CDG')
441
- expect(addresses[0]["city"]).to eq('Paris')
442
- expect(addresses[0]["country"]).to eq('France')
440
+ expect(addresses[0]['street']).to eq('CDG')
441
+ expect(addresses[0]['city']).to eq('Paris')
442
+ expect(addresses[0]['country']).to eq('France')
443
443
 
444
- expect(addresses[1]["street"]).to eq('PGS')
445
- expect(addresses[1]["city"]).to eq('Mikolaiv')
446
- expect(addresses[1]["country"]).to eq('Ukraine')
444
+ expect(addresses[1]['street']).to eq('PGS')
445
+ expect(addresses[1]['city']).to eq('Mikolaiv')
446
+ expect(addresses[1]['country']).to eq('Ukraine')
447
447
  end
448
448
 
449
- context "with :exact option" do
450
- it "should accept partial matches when false" do
449
+ context 'with :exact option' do
450
+ it 'should accept partial matches when false' do
451
451
  @session.click_button('What an Awesome', exact: false)
452
452
  expect(extract_results(@session)['first_name']).to eq('John')
453
453
  end
454
454
 
455
- it "should not accept partial matches when true" do
455
+ it 'should not accept partial matches when true' do
456
456
  expect do
457
457
  @session.click_button('What an Awesome', exact: true)
458
458
  end.to raise_error(Capybara::ElementNotFound)