capybara 2.2.1 → 2.3.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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +26 -0
  3. data/README.md +36 -14
  4. data/lib/capybara.rb +6 -3
  5. data/lib/capybara/driver/base.rb +37 -1
  6. data/lib/capybara/driver/node.rb +10 -2
  7. data/lib/capybara/helpers.rb +21 -13
  8. data/lib/capybara/node/base.rb +12 -7
  9. data/lib/capybara/node/element.rb +17 -1
  10. data/lib/capybara/node/finders.rb +22 -1
  11. data/lib/capybara/node/matchers.rb +26 -5
  12. data/lib/capybara/node/simple.rb +9 -2
  13. data/lib/capybara/rack_test/css_handlers.rb +3 -1
  14. data/lib/capybara/rack_test/form.rb +3 -2
  15. data/lib/capybara/rack_test/node.rb +3 -3
  16. data/lib/capybara/rspec.rb +1 -0
  17. data/lib/capybara/rspec/features.rb +2 -1
  18. data/lib/capybara/rspec/matchers.rb +50 -5
  19. data/lib/capybara/selenium/driver.rb +76 -12
  20. data/lib/capybara/selenium/node.rb +8 -0
  21. data/lib/capybara/server.rb +1 -1
  22. data/lib/capybara/session.rb +234 -29
  23. data/lib/capybara/spec/public/jquery.js +1 -1
  24. data/lib/capybara/spec/public/test.js +7 -0
  25. data/lib/capybara/spec/session/all_spec.rb +88 -17
  26. data/lib/capybara/spec/session/assert_selector.rb +6 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +15 -15
  28. data/lib/capybara/spec/session/body_spec.rb +4 -4
  29. data/lib/capybara/spec/session/check_spec.rb +16 -16
  30. data/lib/capybara/spec/session/choose_spec.rb +5 -5
  31. data/lib/capybara/spec/session/click_button_spec.rb +93 -84
  32. data/lib/capybara/spec/session/click_link_or_button_spec.rb +8 -8
  33. data/lib/capybara/spec/session/click_link_spec.rb +26 -19
  34. data/lib/capybara/spec/session/current_scope_spec.rb +3 -3
  35. data/lib/capybara/spec/session/current_url_spec.rb +8 -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 +22 -22
  39. data/lib/capybara/spec/session/find_button_spec.rb +4 -4
  40. data/lib/capybara/spec/session/find_by_id_spec.rb +3 -3
  41. data/lib/capybara/spec/session/find_field_spec.rb +7 -7
  42. data/lib/capybara/spec/session/find_link_spec.rb +4 -4
  43. data/lib/capybara/spec/session/find_spec.rb +46 -46
  44. data/lib/capybara/spec/session/first_spec.rb +23 -23
  45. data/lib/capybara/spec/session/go_back_spec.rb +3 -3
  46. data/lib/capybara/spec/session/go_forward_spec.rb +4 -4
  47. data/lib/capybara/spec/session/has_button_spec.rb +13 -13
  48. data/lib/capybara/spec/session/has_css_spec.rb +87 -87
  49. data/lib/capybara/spec/session/has_field_spec.rb +87 -87
  50. data/lib/capybara/spec/session/has_link_spec.rb +11 -11
  51. data/lib/capybara/spec/session/has_select_spec.rb +58 -58
  52. data/lib/capybara/spec/session/has_selector_spec.rb +48 -48
  53. data/lib/capybara/spec/session/has_table_spec.rb +7 -7
  54. data/lib/capybara/spec/session/has_text_spec.rb +73 -73
  55. data/lib/capybara/spec/session/has_title_spec.rb +10 -10
  56. data/lib/capybara/spec/session/has_xpath_spec.rb +44 -44
  57. data/lib/capybara/spec/session/headers.rb +1 -1
  58. data/lib/capybara/spec/session/html_spec.rb +9 -9
  59. data/lib/capybara/spec/session/node_spec.rb +81 -65
  60. data/lib/capybara/spec/session/reset_session_spec.rb +15 -15
  61. data/lib/capybara/spec/session/response_code.rb +1 -1
  62. data/lib/capybara/spec/session/save_and_open_screenshot_spec.rb +46 -0
  63. data/lib/capybara/spec/session/save_page_spec.rb +9 -9
  64. data/lib/capybara/spec/session/{screenshot.rb → screenshot_spec.rb} +4 -2
  65. data/lib/capybara/spec/session/select_spec.rb +22 -22
  66. data/lib/capybara/spec/session/text_spec.rb +15 -10
  67. data/lib/capybara/spec/session/title_spec.rb +2 -2
  68. data/lib/capybara/spec/session/uncheck_spec.rb +7 -7
  69. data/lib/capybara/spec/session/unselect_spec.rb +14 -14
  70. data/lib/capybara/spec/session/visit_spec.rb +24 -17
  71. data/lib/capybara/spec/session/window/become_closed_spec.rb +84 -0
  72. data/lib/capybara/spec/session/window/current_window_spec.rb +25 -0
  73. data/lib/capybara/spec/session/window/open_new_window_spec.rb +28 -0
  74. data/lib/capybara/spec/session/window/switch_to_window_spec.rb +114 -0
  75. data/lib/capybara/spec/session/window/window_opened_by_spec.rb +83 -0
  76. data/lib/capybara/spec/session/window/window_spec.rb +141 -0
  77. data/lib/capybara/spec/session/window/windows_spec.rb +31 -0
  78. data/lib/capybara/spec/session/window/within_window_spec.rb +188 -0
  79. data/lib/capybara/spec/session/within_frame_spec.rb +9 -9
  80. data/lib/capybara/spec/session/within_spec.rb +16 -16
  81. data/lib/capybara/spec/spec_helper.rb +14 -4
  82. data/lib/capybara/spec/views/form.erb +7 -0
  83. data/lib/capybara/spec/views/popup_one.erb +1 -1
  84. data/lib/capybara/spec/views/popup_two.erb +1 -1
  85. data/lib/capybara/spec/views/with_js.erb +2 -0
  86. data/lib/capybara/spec/views/with_windows.erb +38 -0
  87. data/lib/capybara/version.rb +1 -1
  88. data/lib/capybara/window.rb +123 -0
  89. data/spec/basic_node_spec.rb +32 -32
  90. data/spec/capybara_spec.rb +6 -7
  91. data/spec/dsl_spec.rb +48 -48
  92. data/spec/fixtures/selenium_driver_rspec_failure.rb +2 -2
  93. data/spec/fixtures/selenium_driver_rspec_success.rb +2 -2
  94. data/spec/rack_test_spec.rb +33 -19
  95. data/spec/result_spec.rb +13 -13
  96. data/spec/rspec/features_spec.rb +20 -15
  97. data/spec/rspec/matchers_spec.rb +109 -109
  98. data/spec/rspec_spec.rb +10 -10
  99. data/spec/selenium_spec.rb +31 -6
  100. data/spec/selenium_spec_chrome.rb +2 -2
  101. data/spec/server_spec.rb +13 -13
  102. metadata +51 -62
  103. checksums.yaml.gz.sig +0 -0
  104. data.tar.gz.sig +0 -0
  105. data/lib/capybara/spec/session/within_window_spec.rb +0 -45
  106. data/lib/capybara/spec/views/within_popups.erb +0 -25
  107. metadata.gz.sig +0 -0
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Capybara do
4
-
3
+ RSpec.describe Capybara do
5
4
  describe 'default_wait_time' do
6
5
  after do
7
6
  Capybara.default_wait_time = @previous_default_time
@@ -10,7 +9,7 @@ describe Capybara do
10
9
  it "should be changeable" do
11
10
  @previous_default_time = Capybara.default_wait_time
12
11
  Capybara.default_wait_time = 5
13
- Capybara.default_wait_time.should == 5
12
+ expect(Capybara.default_wait_time).to eq(5)
14
13
  end
15
14
  end
16
15
 
@@ -21,7 +20,7 @@ describe Capybara do
21
20
  end
22
21
  session = Capybara::Session.new(:schmoo, TestApp)
23
22
  session.visit('/')
24
- session.body.should include("Hello world!")
23
+ expect(session.body).to include("Hello world!")
25
24
  end
26
25
  end
27
26
 
@@ -32,19 +31,19 @@ describe Capybara do
32
31
 
33
32
  it "should default to a proc that calls run_default_server" do
34
33
  mock_app = double('app')
35
- Capybara.should_receive(:run_default_server).with(mock_app, 8000)
34
+ expect(Capybara).to receive(:run_default_server).with(mock_app, 8000)
36
35
  Capybara.server.call(mock_app, 8000)
37
36
  end
38
37
 
39
38
  it "should return a custom server proc" do
40
39
  server = lambda {|app, port|}
41
40
  Capybara.server(&server)
42
- Capybara.server.should == server
41
+ expect(Capybara.server).to eq(server)
43
42
  end
44
43
  end
45
44
  end
46
45
 
47
- describe Capybara::Session do
46
+ RSpec.describe Capybara::Session do
48
47
  context 'with non-existant driver' do
49
48
  it "should raise an error" do
50
49
  expect {
@@ -5,7 +5,7 @@ class TestClass
5
5
  include Capybara::DSL
6
6
  end
7
7
 
8
- Capybara::SpecHelper.run_specs TestClass.new, "DSL", :skip => [
8
+ Capybara::SpecHelper.run_specs TestClass.new, "DSL", :capybara_skip => [
9
9
  :js,
10
10
  :screenshot,
11
11
  :frames,
@@ -14,7 +14,7 @@ Capybara::SpecHelper.run_specs TestClass.new, "DSL", :skip => [
14
14
  :hover
15
15
  ]
16
16
 
17
- describe Capybara::DSL do
17
+ RSpec.describe Capybara::DSL do
18
18
  after do
19
19
  Capybara.session_name = nil
20
20
  Capybara.default_driver = nil
@@ -25,36 +25,36 @@ describe Capybara::DSL do
25
25
 
26
26
  describe '#default_driver' do
27
27
  it "should default to rack_test" do
28
- Capybara.default_driver.should == :rack_test
28
+ expect(Capybara.default_driver).to eq(:rack_test)
29
29
  end
30
30
 
31
31
  it "should be changeable" do
32
32
  Capybara.default_driver = :culerity
33
- Capybara.default_driver.should == :culerity
33
+ expect(Capybara.default_driver).to eq(:culerity)
34
34
  end
35
35
  end
36
36
 
37
37
  describe '#current_driver' do
38
38
  it "should default to the default driver" do
39
- Capybara.current_driver.should == :rack_test
39
+ expect(Capybara.current_driver).to eq(:rack_test)
40
40
  Capybara.default_driver = :culerity
41
- Capybara.current_driver.should == :culerity
41
+ expect(Capybara.current_driver).to eq(:culerity)
42
42
  end
43
43
 
44
44
  it "should be changeable" do
45
45
  Capybara.current_driver = :culerity
46
- Capybara.current_driver.should == :culerity
46
+ expect(Capybara.current_driver).to eq(:culerity)
47
47
  end
48
48
  end
49
49
 
50
50
  describe '#javascript_driver' do
51
51
  it "should default to selenium" do
52
- Capybara.javascript_driver.should == :selenium
52
+ expect(Capybara.javascript_driver).to eq(:selenium)
53
53
  end
54
54
 
55
55
  it "should be changeable" do
56
56
  Capybara.javascript_driver = :culerity
57
- Capybara.javascript_driver.should == :culerity
57
+ expect(Capybara.javascript_driver).to eq(:culerity)
58
58
  end
59
59
  end
60
60
 
@@ -62,26 +62,26 @@ describe Capybara::DSL do
62
62
  it "should restore the default driver" do
63
63
  Capybara.current_driver = :culerity
64
64
  Capybara.use_default_driver
65
- Capybara.current_driver.should == :rack_test
65
+ expect(Capybara.current_driver).to eq(:rack_test)
66
66
  end
67
67
  end
68
68
 
69
69
  describe '#using_driver' do
70
70
  before do
71
- Capybara.current_driver.should_not == :selenium
71
+ expect(Capybara.current_driver).not_to eq(:selenium)
72
72
  end
73
73
 
74
74
  it 'should set the driver using Capybara.current_driver=' do
75
75
  driver = nil
76
76
  Capybara.using_driver(:selenium) { driver = Capybara.current_driver }
77
- driver.should == :selenium
77
+ expect(driver).to eq(:selenium)
78
78
  end
79
79
 
80
80
  it 'should return the driver to default if it has not been changed' do
81
81
  Capybara.using_driver(:selenium) do
82
- Capybara.current_driver.should == :selenium
82
+ expect(Capybara.current_driver).to eq(:selenium)
83
83
  end
84
- Capybara.current_driver.should == Capybara.default_driver
84
+ expect(Capybara.current_driver).to eq(Capybara.default_driver)
85
85
  end
86
86
 
87
87
  it 'should reset the driver even if an exception occurs' do
@@ -90,24 +90,24 @@ describe Capybara::DSL do
90
90
  Capybara.using_driver(:selenium) { raise "ohnoes!" }
91
91
  rescue Exception
92
92
  end
93
- Capybara.current_driver.should == driver_before_block
93
+ expect(Capybara.current_driver).to eq(driver_before_block)
94
94
  end
95
95
 
96
96
  it 'should return the driver to what it was previously' do
97
97
  Capybara.current_driver = :selenium
98
98
  Capybara.using_driver(:culerity) do
99
99
  Capybara.using_driver(:rack_test) do
100
- Capybara.current_driver.should == :rack_test
100
+ expect(Capybara.current_driver).to eq(:rack_test)
101
101
  end
102
- Capybara.current_driver.should == :culerity
102
+ expect(Capybara.current_driver).to eq(:culerity)
103
103
  end
104
- Capybara.current_driver.should == :selenium
104
+ expect(Capybara.current_driver).to eq(:selenium)
105
105
  end
106
106
 
107
107
  it 'should yield the passed block' do
108
108
  called = false
109
109
  Capybara.using_driver(:selenium) { called = true }
110
- called.should == true
110
+ expect(called).to eq(true)
111
111
  end
112
112
  end
113
113
 
@@ -125,8 +125,8 @@ describe Capybara::DSL do
125
125
  Capybara.using_wait_time 6 do
126
126
  in_block = Capybara.default_wait_time
127
127
  end
128
- in_block.should == 6
129
- Capybara.default_wait_time.should == @previous_wait_time
128
+ expect(in_block).to eq(6)
129
+ expect(Capybara.default_wait_time).to eq(@previous_wait_time)
130
130
  end
131
131
 
132
132
  it "should ensure wait time is reset" do
@@ -135,70 +135,70 @@ describe Capybara::DSL do
135
135
  raise "hell"
136
136
  end
137
137
  end.to raise_error
138
- Capybara.default_wait_time.should == @previous_wait_time
138
+ expect(Capybara.default_wait_time).to eq(@previous_wait_time)
139
139
  end
140
140
  end
141
141
 
142
142
  describe '#app' do
143
143
  it "should be changeable" do
144
144
  Capybara.app = "foobar"
145
- Capybara.app.should == 'foobar'
145
+ expect(Capybara.app).to eq('foobar')
146
146
  end
147
147
  end
148
148
 
149
149
  describe '#current_session' do
150
150
  it "should choose a session object of the current driver type" do
151
- Capybara.current_session.should be_a(Capybara::Session)
151
+ expect(Capybara.current_session).to be_a(Capybara::Session)
152
152
  end
153
153
 
154
154
  it "should use #app as the application" do
155
155
  Capybara.app = proc {}
156
- Capybara.current_session.app.should == Capybara.app
156
+ expect(Capybara.current_session.app).to eq(Capybara.app)
157
157
  end
158
158
 
159
159
  it "should change with the current driver" do
160
- Capybara.current_session.mode.should == :rack_test
160
+ expect(Capybara.current_session.mode).to eq(:rack_test)
161
161
  Capybara.current_driver = :selenium
162
- Capybara.current_session.mode.should == :selenium
162
+ expect(Capybara.current_session.mode).to eq(:selenium)
163
163
  end
164
164
 
165
165
  it "should be persistent even across driver changes" do
166
166
  object_id = Capybara.current_session.object_id
167
- Capybara.current_session.object_id.should == object_id
167
+ expect(Capybara.current_session.object_id).to eq(object_id)
168
168
  Capybara.current_driver = :selenium
169
- Capybara.current_session.mode.should == :selenium
170
- Capybara.current_session.object_id.should_not == object_id
169
+ expect(Capybara.current_session.mode).to eq(:selenium)
170
+ expect(Capybara.current_session.object_id).not_to eq(object_id)
171
171
 
172
172
  Capybara.current_driver = :rack_test
173
- Capybara.current_session.object_id.should == object_id
173
+ expect(Capybara.current_session.object_id).to eq(object_id)
174
174
  end
175
175
 
176
176
  it "should change when changing application" do
177
177
  object_id = Capybara.current_session.object_id
178
- Capybara.current_session.object_id.should == object_id
178
+ expect(Capybara.current_session.object_id).to eq(object_id)
179
179
  Capybara.app = proc {}
180
- Capybara.current_session.object_id.should_not == object_id
181
- Capybara.current_session.app.should == Capybara.app
180
+ expect(Capybara.current_session.object_id).not_to eq(object_id)
181
+ expect(Capybara.current_session.app).to eq(Capybara.app)
182
182
  end
183
183
 
184
184
  it "should change when the session name changes" do
185
185
  object_id = Capybara.current_session.object_id
186
186
  Capybara.session_name = :administrator
187
- Capybara.session_name.should == :administrator
188
- Capybara.current_session.object_id.should_not == object_id
187
+ expect(Capybara.session_name).to eq(:administrator)
188
+ expect(Capybara.current_session.object_id).not_to eq(object_id)
189
189
  Capybara.session_name = :default
190
- Capybara.session_name.should == :default
191
- Capybara.current_session.object_id.should == object_id
190
+ expect(Capybara.session_name).to eq(:default)
191
+ expect(Capybara.current_session.object_id).to eq(object_id)
192
192
  end
193
193
  end
194
194
 
195
195
  describe "#using_session" do
196
196
  it "should change the session name for the duration of the block" do
197
- Capybara.session_name.should == :default
197
+ expect(Capybara.session_name).to eq(:default)
198
198
  Capybara.using_session(:administrator) do
199
- Capybara.session_name.should == :administrator
199
+ expect(Capybara.session_name).to eq(:administrator)
200
200
  end
201
- Capybara.session_name.should == :default
201
+ expect(Capybara.session_name).to eq(:default)
202
202
  end
203
203
 
204
204
  it "should reset the session to the default, even if an exception occurs" do
@@ -208,19 +208,19 @@ describe Capybara::DSL do
208
208
  end
209
209
  rescue Exception
210
210
  end
211
- Capybara.session_name.should == :default
211
+ expect(Capybara.session_name).to eq(:default)
212
212
  end
213
213
 
214
214
  it "should yield the passed block" do
215
215
  called = false
216
216
  Capybara.using_session(:administrator) { called = true }
217
- called.should == true
217
+ expect(called).to eq(true)
218
218
  end
219
219
  end
220
220
 
221
221
  describe "#session_name" do
222
222
  it "should default to :default" do
223
- Capybara.session_name.should == :default
223
+ expect(Capybara.session_name).to eq(:default)
224
224
  end
225
225
  end
226
226
 
@@ -232,22 +232,22 @@ describe Capybara::DSL do
232
232
  it "should be possible to include it in another class" do
233
233
  @session.visit('/with_html')
234
234
  @session.click_link('ullamco')
235
- @session.body.should include('Another World')
235
+ expect(@session.body).to include('Another World')
236
236
  end
237
237
 
238
238
  it "should provide a 'page' shortcut for more expressive tests" do
239
239
  @session.page.visit('/with_html')
240
240
  @session.page.click_link('ullamco')
241
- @session.page.body.should include('Another World')
241
+ expect(@session.page.body).to include('Another World')
242
242
  end
243
243
 
244
244
  it "should provide an 'using_session' shortcut" do
245
- Capybara.should_receive(:using_session).with(:name)
245
+ expect(Capybara).to receive(:using_session).with(:name)
246
246
  @session.using_session(:name)
247
247
  end
248
248
 
249
249
  it "should provide a 'using_wait_time' shortcut" do
250
- Capybara.should_receive(:using_wait_time).with(6)
250
+ expect(Capybara).to receive(:using_wait_time).with(6)
251
251
  @session.using_wait_time(6)
252
252
  end
253
253
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Capybara::Selenium::Driver do
3
+ RSpec.describe Capybara::Selenium::Driver do
4
4
  it "should exit with a non-zero exit status" do
5
5
  browser = Capybara::Selenium::Driver.new(TestApp).browser
6
- true.should == false
6
+ expect(true).to eq(false)
7
7
  end
8
8
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Capybara::Selenium::Driver do
3
+ RSpec.describe Capybara::Selenium::Driver do
4
4
  it "should exit with a zero exit status" do
5
5
  browser = Capybara::Selenium::Driver.new(TestApp).browser
6
- true.should == true
6
+ expect(true).to eq(true)
7
7
  end
8
8
  end
@@ -4,7 +4,7 @@ module TestSessions
4
4
  RackTest = Capybara::Session.new(:rack_test, TestApp)
5
5
  end
6
6
 
7
- Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :skip => [
7
+ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :capybara_skip => [
8
8
  :js,
9
9
  :screenshot,
10
10
  :frames,
@@ -13,7 +13,7 @@ Capybara::SpecHelper.run_specs TestSessions::RackTest, "RackTest", :skip => [
13
13
  :hover
14
14
  ]
15
15
 
16
- describe Capybara::Session do
16
+ RSpec.describe Capybara::Session do
17
17
  context 'with rack test driver' do
18
18
  before do
19
19
  @session = TestSessions::RackTest
@@ -21,13 +21,13 @@ describe Capybara::Session do
21
21
 
22
22
  describe '#driver' do
23
23
  it "should be a rack test driver" do
24
- @session.driver.should be_an_instance_of(Capybara::RackTest::Driver)
24
+ expect(@session.driver).to be_an_instance_of(Capybara::RackTest::Driver)
25
25
  end
26
26
  end
27
27
 
28
28
  describe '#mode' do
29
29
  it "should remember the mode" do
30
- @session.mode.should == :rack_test
30
+ expect(@session.mode).to eq(:rack_test)
31
31
  end
32
32
  end
33
33
 
@@ -36,21 +36,21 @@ describe Capybara::Session do
36
36
  @session.driver.options[:respect_data_method] = true
37
37
  @session.visit "/with_html"
38
38
  @session.click_link "A link with data-method"
39
- @session.html.should include('The requested object was deleted')
39
+ expect(@session.html).to include('The requested object was deleted')
40
40
  end
41
41
 
42
42
  it "should not use data-method if option is false" do
43
43
  @session.driver.options[:respect_data_method] = false
44
44
  @session.visit "/with_html"
45
45
  @session.click_link "A link with data-method"
46
- @session.html.should include('Not deleted')
46
+ expect(@session.html).to include('Not deleted')
47
47
  end
48
48
 
49
49
  it "should use data-method if available even if it's capitalized" do
50
50
  @session.driver.options[:respect_data_method] = true
51
51
  @session.visit "/with_html"
52
52
  @session.click_link "A link with capitalized data-method"
53
- @session.html.should include('The requested object was deleted')
53
+ expect(@session.html).to include('The requested object was deleted')
54
54
  end
55
55
 
56
56
  after do
@@ -63,14 +63,14 @@ describe Capybara::Session do
63
63
  it "should submit an empty form-data section if no file is submitted" do
64
64
  @session.visit("/form")
65
65
  @session.click_button("Upload Empty")
66
- @session.html.should include('Successfully ignored empty file field.')
66
+ expect(@session.html).to include('Successfully ignored empty file field.')
67
67
  end
68
68
  end
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
- describe Capybara::RackTest::Driver do
73
+ RSpec.describe Capybara::RackTest::Driver do
74
74
  before do
75
75
  @driver = TestSessions::RackTest.driver
76
76
  end
@@ -79,27 +79,27 @@ describe Capybara::RackTest::Driver do
79
79
  it 'should always set headers' do
80
80
  @driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
81
81
  @driver.visit('/get_header')
82
- @driver.html.should include('foobar')
82
+ expect(@driver.html).to include('foobar')
83
83
  end
84
84
 
85
85
  it 'should keep headers on link clicks' do
86
86
  @driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
87
87
  @driver.visit('/header_links')
88
88
  @driver.find_xpath('.//a').first.click
89
- @driver.html.should include('foobar')
89
+ expect(@driver.html).to include('foobar')
90
90
  end
91
91
 
92
92
  it 'should keep headers on form submit' do
93
93
  @driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
94
94
  @driver.visit('/header_links')
95
95
  @driver.find_xpath('.//input').first.click
96
- @driver.html.should include('foobar')
96
+ expect(@driver.html).to include('foobar')
97
97
  end
98
98
 
99
99
  it 'should keep headers on redirects' do
100
100
  @driver = Capybara::RackTest::Driver.new(TestApp, :headers => {'HTTP_FOO' => 'foobar'})
101
101
  @driver.visit('/get_header_via_redirect')
102
- @driver.html.should include('foobar')
102
+ expect(@driver.html).to include('foobar')
103
103
  end
104
104
  end
105
105
 
@@ -108,16 +108,16 @@ describe Capybara::RackTest::Driver do
108
108
  @driver = Capybara::RackTest::Driver.new(TestApp)
109
109
 
110
110
  @driver.visit('/redirect')
111
- @driver.response.header['Location'].should be_nil
112
- @driver.browser.current_url.should match %r{/landed$}
111
+ expect(@driver.response.header['Location']).to be_nil
112
+ expect(@driver.browser.current_url).to match %r{/landed$}
113
113
  end
114
114
 
115
115
  it "is possible to not follow redirects" do
116
116
  @driver = Capybara::RackTest::Driver.new(TestApp, :follow_redirects => false)
117
117
 
118
118
  @driver.visit('/redirect')
119
- @driver.response.header['Location'].should match %r{/redirect_again$}
120
- @driver.browser.current_url.should match %r{/redirect$}
119
+ expect(@driver.response.header['Location']).to match %r{/redirect_again$}
120
+ expect(@driver.browser.current_url).to match %r{/redirect$}
121
121
  end
122
122
  end
123
123
 
@@ -129,7 +129,7 @@ describe Capybara::RackTest::Driver do
129
129
 
130
130
  it "should follow 5 redirects" do
131
131
  @driver.visit("/redirect/5/times")
132
- @driver.html.should include('redirection complete')
132
+ expect(@driver.html).to include('redirection complete')
133
133
  end
134
134
 
135
135
  it "should not follow more than 6 redirects" do
@@ -146,7 +146,7 @@ describe Capybara::RackTest::Driver do
146
146
 
147
147
  it "should follow 21 redirects" do
148
148
  @driver.visit("/redirect/21/times")
149
- @driver.html.should include('redirection complete')
149
+ expect(@driver.html).to include('redirection complete')
150
150
  end
151
151
 
152
152
  it "should not follow more than 21 redirects" do
@@ -157,3 +157,17 @@ describe Capybara::RackTest::Driver do
157
157
  end
158
158
  end
159
159
  end
160
+
161
+ module CSSHandlerIncludeTester
162
+ def dont_extend_css_handler
163
+ raise 'should never be called'
164
+ end
165
+ end
166
+ include CSSHandlerIncludeTester
167
+
168
+ RSpec.describe Capybara::RackTest::CSSHandlers do
169
+ it "should not be extended by global includes" do
170
+ expect(Capybara::RackTest::CSSHandlers.new).not_to respond_to(:dont_extend_css_handler)
171
+ end
172
+ end
173
+