capybara 2.1.0 → 2.2.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 (58) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/History.md +48 -1
  4. data/README.md +22 -18
  5. data/lib/capybara/cucumber.rb +0 -2
  6. data/lib/capybara/driver/base.rb +9 -1
  7. data/lib/capybara/empty.html +4 -0
  8. data/lib/capybara/node/actions.rb +1 -1
  9. data/lib/capybara/node/finders.rb +3 -3
  10. data/lib/capybara/node/matchers.rb +22 -18
  11. data/lib/capybara/node/simple.rb +5 -3
  12. data/lib/capybara/query.rb +1 -0
  13. data/lib/capybara/rack_test/browser.rb +5 -4
  14. data/lib/capybara/rack_test/form.rb +5 -2
  15. data/lib/capybara/rack_test/node.rb +2 -1
  16. data/lib/capybara/result.rb +2 -1
  17. data/lib/capybara/rspec/features.rb +2 -0
  18. data/lib/capybara/rspec/matchers.rb +6 -6
  19. data/lib/capybara/rspec.rb +7 -0
  20. data/lib/capybara/selector.rb +3 -1
  21. data/lib/capybara/selenium/driver.rb +14 -2
  22. data/lib/capybara/selenium/node.rb +18 -5
  23. data/lib/capybara/server.rb +3 -7
  24. data/lib/capybara/session.rb +59 -17
  25. data/lib/capybara/spec/public/test.js +1 -1
  26. data/lib/capybara/spec/session/assert_selector.rb +18 -0
  27. data/lib/capybara/spec/session/attach_file_spec.rb +6 -1
  28. data/lib/capybara/spec/session/check_spec.rb +14 -0
  29. data/lib/capybara/spec/session/choose_spec.rb +14 -0
  30. data/lib/capybara/spec/session/click_button_spec.rb +20 -1
  31. data/lib/capybara/spec/session/fill_in_spec.rb +18 -2
  32. data/lib/capybara/spec/session/go_back_spec.rb +10 -0
  33. data/lib/capybara/spec/session/go_forward_spec.rb +12 -0
  34. data/lib/capybara/spec/session/has_button_spec.rb +24 -0
  35. data/lib/capybara/spec/session/has_field_spec.rb +48 -0
  36. data/lib/capybara/spec/session/has_text_spec.rb +18 -0
  37. data/lib/capybara/spec/session/node_spec.rb +36 -1
  38. data/lib/capybara/spec/session/reset_session_spec.rb +17 -2
  39. data/lib/capybara/spec/session/save_page_spec.rb +10 -4
  40. data/lib/capybara/spec/session/visit_spec.rb +16 -0
  41. data/lib/capybara/spec/session/within_frame_spec.rb +7 -0
  42. data/lib/capybara/spec/session/within_window_spec.rb +7 -0
  43. data/lib/capybara/spec/test_app.rb +1 -0
  44. data/lib/capybara/spec/views/form.erb +40 -0
  45. data/lib/capybara/spec/views/with_html.erb +5 -0
  46. data/lib/capybara/spec/views/with_js.erb +8 -0
  47. data/lib/capybara/version.rb +1 -1
  48. data/lib/capybara.rb +28 -3
  49. data/spec/capybara_spec.rb +1 -1
  50. data/spec/result_spec.rb +14 -0
  51. data/spec/rspec/features_spec.rb +15 -0
  52. data/spec/rspec/matchers_spec.rb +24 -1
  53. data/spec/selenium_spec.rb +9 -2
  54. data/spec/selenium_spec_chrome.rb +21 -0
  55. data/spec/server_spec.rb +13 -5
  56. data.tar.gz.sig +0 -0
  57. metadata +59 -97
  58. metadata.gz.sig +0 -0
@@ -58,10 +58,25 @@ Capybara::SpecHelper.spec "node" do
58
58
  @session.find('//textarea[@id="additional_newline"]').value.should == "\nbanana"
59
59
  end
60
60
 
61
+ it "should not swallow leading newlines for set content in textarea" do
62
+ @session.find('//textarea[@id="normal"]').set("\nbanana")
63
+ @session.find('//textarea[@id="normal"]').value.should == "\nbanana"
64
+ end
65
+
61
66
  it "return any HTML content in textarea" do
62
67
  @session.find('//textarea[1]').set("some <em>html</em> here")
63
68
  @session.find('//textarea[1]').value.should == "some <em>html</em> here"
64
69
  end
70
+
71
+ it "defaults to 'on' for checkbox" do
72
+ @session.visit('/form')
73
+ @session.find('//input[@id="valueless_checkbox"]').value.should == 'on'
74
+ end
75
+
76
+ it "defaults to 'on' for radio buttons" do
77
+ @session.visit('/form')
78
+ @session.find('//input[@id="valueless_radio"]').value.should == 'on'
79
+ end
65
80
  end
66
81
 
67
82
  describe "#set" do
@@ -88,6 +103,25 @@ Capybara::SpecHelper.spec "node" do
88
103
  @session.first('//textarea[@readonly]').set('changed')
89
104
  @session.first('//textarea[@readonly]').value.should == 'textarea should not change'
90
105
  end
106
+
107
+ it 'should allow me to change the contents of a contenteditable element', :requires => [:js] do
108
+ @session.visit('/with_js')
109
+ @session.find(:css,'#existing_content_editable').set('WYSIWYG')
110
+ @session.find(:css,'#existing_content_editable').text.should == 'WYSIWYG'
111
+ end
112
+
113
+ it 'should allow me to set the contents of a contenteditable element', :requires => [:js] do
114
+ @session.visit('/with_js')
115
+ @session.find(:css,'#blank_content_editable').set('WYSIWYG')
116
+ @session.find(:css,'#blank_content_editable').text.should == 'WYSIWYG'
117
+ end
118
+
119
+ it 'should allow me to change the contents of a contenteditable elements child', :requires => [:js] do
120
+ pending "Selenium doesn't like editing nested contents"
121
+ @session.visit('/with_js')
122
+ @session.find(:css,'#existing_content_editable_child').set('WYSIWYG')
123
+ @session.find(:css,'#existing_content_editable_child').text.should == 'WYSIWYG'
124
+ end
91
125
  end
92
126
 
93
127
  describe "#tag_name" do
@@ -125,6 +159,8 @@ Capybara::SpecHelper.spec "node" do
125
159
 
126
160
  @session.find('//div[@id="hidden"]').should_not be_visible
127
161
  @session.find('//div[@id="hidden_via_ancestor"]').should_not be_visible
162
+ @session.find('//div[@id="hidden_attr"]').should_not be_visible
163
+ @session.find('//a[@id="hidden_attr_via_ancestor"]').should_not be_visible
128
164
  end
129
165
  end
130
166
 
@@ -178,7 +214,6 @@ Capybara::SpecHelper.spec "node" do
178
214
 
179
215
  describe '#hover', :requires => [:hover] do
180
216
  it "should allow hovering on an element" do
181
- pending "Selenium with firefox doesn't currently work with this (selenium with chrome does)" if @session.respond_to?(:mode) && @session.mode == :selenium && @session.driver.browser.browser == :firefox
182
217
  @session.visit('/with_hover')
183
218
  @session.find(:css,'.hidden_until_hover', :visible => false).should_not be_visible
184
219
  @session.find(:css,'.wrapper').hover
@@ -16,9 +16,18 @@ Capybara::SpecHelper.spec '#reset_session!' do
16
16
  @session.current_path.should == '/foo'
17
17
 
18
18
  @session.reset_session!
19
- [nil, '', 'about:blank'].should include @session.current_url
19
+ [
20
+ ->(v) { v == nil },
21
+ ->(v) { v == '' },
22
+ ->(v) { v == 'about:blank' },
23
+ ->(v) { v.end_with? Capybara::EMPTY_HTML_FILE_PATH } # allow file:// protocol
24
+ ].any? { |p| p.(@session.current_url) }.should be_true
25
+ [
26
+ ->(v) { v == '' },
27
+ ->(v) { v == nil },
28
+ ->(v) { v == Capybara::EMPTY_HTML_FILE_PATH }
29
+ ].any? { |p| p.(@session.current_path) }.should be_true
20
30
  @session.current_host.should be_nil
21
- @session.current_path.should be_nil
22
31
  end
23
32
 
24
33
  it "resets page body" do
@@ -31,6 +40,12 @@ Capybara::SpecHelper.spec '#reset_session!' do
31
40
  @session.should have_no_selector('.//h1')
32
41
  end
33
42
 
43
+ it "is synchronous" do
44
+ @session.visit("/with_html")
45
+ @session.reset_session!
46
+ @session.should have_no_selector :xpath, "/html/body/*", wait: false
47
+ end
48
+
34
49
  it "raises any errors caught inside the server", :requires => [:server] do
35
50
  quietly { @session.visit("/error") }
36
51
  expect do
@@ -37,11 +37,17 @@ Capybara::SpecHelper.spec '#save_page' do
37
37
  File.read("capybara-001122.html").should include("Another World")
38
38
  end
39
39
 
40
- it "returns the filename" do
40
+ it "returns an absolute path in pwd" do
41
41
  result = @session.save_page
42
- path = Dir.glob("capybara-*.html").first
43
- filename = path.split("/").last
44
- result.should == filename
42
+ path = File.expand_path(Dir.glob("capybara-*.html").first, Dir.pwd)
43
+ result.should == path
44
+ end
45
+
46
+ it "returns an absolute path in given directory" do
47
+ Capybara.save_and_open_page_path = alternative_path
48
+ result = @session.save_page
49
+ path = File.expand_path(Dir.glob(alternative_path + "/capybara-*.html").first, alternative_path)
50
+ result.should == path
45
51
  end
46
52
 
47
53
  context "asset_host contains a string" do
@@ -17,6 +17,15 @@ Capybara::SpecHelper.spec '#visit' do
17
17
  @session.should have_content('Another World')
18
18
  end
19
19
 
20
+ it "should fetch a response when absolute URI doesn't have a trailing slash" do
21
+ # Preparation
22
+ @session.visit('/foo/bar')
23
+ root_uri = URI.parse(@session.current_url)
24
+
25
+ @session.visit("http://localhost:#{root_uri.port}")
26
+ @session.should have_content('Hello world!')
27
+ end
28
+
20
29
  context "when Capybara.always_include_port is true" do
21
30
 
22
31
  let(:root_uri) do
@@ -86,4 +95,11 @@ Capybara::SpecHelper.spec '#visit' do
86
95
  @session.find('//input').click
87
96
  @session.should have_content %r{http://.*/referer_base}
88
97
  end
98
+
99
+ it "can set cookie if a blank path is specified" do
100
+ @session.visit("")
101
+ @session.visit('/get_cookie')
102
+ @session.should have_content('root cookie')
103
+ end
104
+
89
105
  end
@@ -42,4 +42,11 @@ Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
42
42
  end
43
43
  end
44
44
  end
45
+ it "should reset scope when changing frames" do
46
+ @session.within(:css, '#divInMainWindow') do
47
+ @session.within_frame 'parentFrame' do
48
+ @session.has_selector?(:css, "iframe#childFrame").should be_true
49
+ end
50
+ end
51
+ end
45
52
  end
@@ -35,4 +35,11 @@ Capybara::SpecHelper.spec '#within_window', :requires => [:windows] do
35
35
  end
36
36
  @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
37
37
  end
38
+ it "should reset scope when switching windows" do
39
+ @session.within(:css, '#divInMainWindow') do
40
+ @session.within_window("secondPopup") do
41
+ @session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
42
+ end
43
+ end
44
+ end
38
45
  end
@@ -13,6 +13,7 @@ class TestApp < Sinatra::Base
13
13
  # Also check lib/capybara/spec/views/*.erb for pages not listed here
14
14
 
15
15
  get '/' do
16
+ response.set_cookie('capybara', { value: 'root cookie', domain: request.host, path: request.path} )
16
17
  'Hello world! <a href="with_html">Relative</a>'
17
18
  end
18
19
 
@@ -136,6 +136,14 @@
136
136
  <textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
137
137
  <p>
138
138
 
139
+ <p>
140
+ <label for="form_newline">NewLine</label></br>
141
+ <textarea name="form[newline]" id="form_newline">
142
+
143
+ New line after and before textarea tag
144
+ </textarea>
145
+ </p>
146
+
139
147
  <p>
140
148
  <input type="radio" name="form[gender]" value="male" id="gender_male"/>
141
149
  <label for="gender_male">Male</label>
@@ -153,6 +161,13 @@
153
161
  <input type="checkbox" value="hamster" name="form[pets][]" id="form_pets_hamster" checked="checked"/>
154
162
  <label for="form_pets_hamster">Hamster</label>
155
163
  </p>
164
+
165
+ <p>
166
+ <input type="checkbox" name="form[valueless_checkbox]" id="valueless_checkbox" checked="checked"/>
167
+ <label for="valueless_checkbox">Valueless Checkbox</label>
168
+ <input type="radio" name="form[valueless_radio]" id="valueless_radio" checked="checked"/>
169
+ <label for="valueless_radio">Valueless Radio</label>
170
+ </p>
156
171
 
157
172
  <p>
158
173
  <label for="form_languages">Languages</label>
@@ -234,6 +249,13 @@
234
249
  </label>
235
250
  </p>
236
251
 
252
+ <p>
253
+ <label for="form_disabled_unchecked_checkbox">
254
+ Disabled Unchecked Checkbox
255
+ <input type="checkbox" name="form[disabled_unchecked_checkbox]" value="Should not see me" id="form_disabled_unchecked_checkbox" disabled="disabled" />
256
+ </label>
257
+ </p>
258
+
237
259
  <p>
238
260
  <label for="form_disabled_radio">
239
261
  Disabled Radio
@@ -283,6 +305,8 @@
283
305
  <button type="submit" name="form[other_form_button]" value="other_form_button" form="form1">Form1</button>
284
306
  </form>
285
307
 
308
+ <button type="submit" name="form[no_form_button]" value="no_form_button">No Form</button>
309
+
286
310
  <textarea name="form[outside_textarea]" form="form1">Some text here</textarea>
287
311
  <select name="form[outside_select]" form="form1">
288
312
  <option>Lisp</option>
@@ -317,6 +341,20 @@
317
341
  <p>
318
342
  </form>
319
343
 
344
+ <form action="/upload_empty" method="post" enctype="multipart/form-data">
345
+ <p>
346
+ <label>
347
+ <input type="file" name="form[file]" multiple="multiple"/>
348
+ Multiple empty files
349
+ </label>
350
+ </p>
351
+
352
+ <p>
353
+ <input type="hidden" name="form[dummy]" value="ensure params[:form] exists"/>
354
+ <input type="submit" value="Upload Empty Multiple"/>
355
+ <p>
356
+ </form>
357
+
320
358
  <form action="/upload" method="post" enctype="multipart/form-data">
321
359
  <p>
322
360
  <label for="form_file_name">File Name</label>
@@ -402,3 +440,5 @@
402
440
  <input type="submit" name="form[no_action]" value="No Action" />
403
441
  </p>
404
442
  </form>
443
+
444
+
@@ -66,6 +66,11 @@ banana</textarea>
66
66
  <a href="/with_simple_html" title="hidden link" class="simple">hidden link</a>
67
67
  </div>
68
68
 
69
+ <div id="hidden_attr" hidden="hidden">
70
+ <a id="hidden_attr_via_ancestor">hidden attribute ancestor link</a>
71
+ </div>
72
+
73
+
69
74
  <div id="hidden-text">
70
75
  Some of this text is <em style="display:none">hidden!</em>
71
76
  </div>
@@ -36,6 +36,14 @@
36
36
  <input type="text" name="with_change_event" value="default value" id="with_change_event"/>
37
37
  </p>
38
38
 
39
+ <p>
40
+ <div contenteditable='true' id='existing_content_editable'>Editable content</div>
41
+ <div contenteditable='true' id='blank_content_editable' style='height: 1em;'></div>
42
+ <div contenteditable='true' style='height: 1em;'>
43
+ <div id='existing_content_editable_child' style='height: 1em;'>Content</div>
44
+ </div>
45
+ </p>
46
+
39
47
  <p>
40
48
  <input type="checkbox" id="checkbox_with_event"/>
41
49
  </p>
@@ -1,3 +1,3 @@
1
1
  module Capybara
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
data/lib/capybara.rb CHANGED
@@ -14,12 +14,14 @@ module Capybara
14
14
  class NotSupportedByDriverError < CapybaraError; end
15
15
  class InfiniteRedirectError < CapybaraError; end
16
16
 
17
+ EMPTY_HTML_FILE_PATH = File.expand_path('./capybara/empty.html', File.dirname(__FILE__))
18
+
17
19
  class << self
18
20
  attr_accessor :asset_host, :app_host, :run_server, :default_host, :always_include_port
19
- attr_accessor :server_host, :server_port, :exact, :match, :exact_options, :visible_text_only
21
+ attr_accessor :server_port, :exact, :match, :exact_options, :visible_text_only
20
22
  attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
21
23
  attr_accessor :save_and_open_page_path, :automatic_reload, :raise_server_errors
22
- attr_writer :default_driver, :current_driver, :javascript_driver, :session_name
24
+ attr_writer :default_driver, :current_driver, :javascript_driver, :session_name, :server_host
23
25
  attr_accessor :app
24
26
 
25
27
  ##
@@ -166,7 +168,7 @@ module Capybara
166
168
  #
167
169
  def run_default_server(app, port)
168
170
  require 'rack/handler/webrick'
169
- Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
171
+ Rack::Handler::WEBrick.run(app, :Host => server_host, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
170
172
  end
171
173
 
172
174
  ##
@@ -214,6 +216,14 @@ module Capybara
214
216
  @current_driver = previous_driver
215
217
  end
216
218
 
219
+ ##
220
+ #
221
+ # @return [String] The IP address bound by default server
222
+ #
223
+ def server_host
224
+ @server_host || '127.0.0.1'
225
+ end
226
+
217
227
  ##
218
228
  #
219
229
  # Yield a block using a specific wait time
@@ -267,6 +277,21 @@ module Capybara
267
277
  self.session_name = :default
268
278
  end
269
279
 
280
+ ##
281
+ #
282
+ # Parse raw html into a document using Nokogiri, and adjust textarea contents as defined by the spec.
283
+ #
284
+ # @param [String] html The raw html
285
+ # @return [Nokogiri::HTML::Document] HTML document
286
+ #
287
+ def HTML(html)
288
+ Nokogiri::HTML(html).tap do |document|
289
+ document.xpath('//textarea').each do |textarea|
290
+ textarea.content=textarea.content.sub(/\A\n/,'')
291
+ end
292
+ end
293
+ end
294
+
270
295
  def included(base)
271
296
  base.send(:include, Capybara::DSL)
272
297
  warn "`include Capybara` is deprecated. Please use `include Capybara::DSL` instead."
@@ -31,7 +31,7 @@ describe Capybara do
31
31
  end
32
32
 
33
33
  it "should default to a proc that calls run_default_server" do
34
- mock_app = mock('app')
34
+ mock_app = double('app')
35
35
  Capybara.should_receive(:run_default_server).with(mock_app, 8000)
36
36
  Capybara.server.call(mock_app, 8000)
37
37
  end
data/spec/result_spec.rb CHANGED
@@ -28,6 +28,10 @@ describe Capybara::Result do
28
28
  result.last.text == 'Delta'
29
29
  end
30
30
 
31
+ it 'can supports values_at method' do
32
+ result.values_at(0, 2).map(&:text).should == %w(Alpha Gamma)
33
+ end
34
+
31
35
  it "can return an element by its index" do
32
36
  result.at(1).text.should == 'Beta'
33
37
  result[2].text.should == 'Gamma'
@@ -48,4 +52,14 @@ describe Capybara::Result do
48
52
  memo += element.text[0]
49
53
  end.should == 'ABGD'
50
54
  end
55
+
56
+ it 'can be sampled' do
57
+ result.should include(result.sample)
58
+ end
59
+
60
+ it 'can be indexed' do
61
+ result.index do |el|
62
+ el.text == 'Gamma'
63
+ end.should == 2
64
+ end
51
65
  end
@@ -34,6 +34,21 @@ feature "Capybara's feature DSL" do
34
34
  scenario "doesn't pollute the Object namespace" do
35
35
  Object.new.respond_to?(:feature, true).should be_false
36
36
  end
37
+
38
+ feature 'nested features' do
39
+ scenario 'work as expected' do
40
+ visit '/'
41
+ page.should have_content 'Hello world!'
42
+ end
43
+
44
+ scenario 'are marked in the metadata as capybara_feature' do
45
+ example.metadata[:capybara_feature].should be_true
46
+ end
47
+
48
+ scenario 'have a type of :feature' do
49
+ example.metadata[:type].should eq :feature
50
+ end
51
+ end
37
52
  end
38
53
 
39
54
  feature "given and given! aliases to let and let!" do
@@ -519,21 +519,44 @@ describe Capybara::RSpecMatchers do
519
519
  end
520
520
 
521
521
  describe "have_field matcher" do
522
- let(:html) { '<p><label>Text field<input type="text"/></label></p>' }
522
+ let(:html) { '<p><label>Text field<input type="text" value="some value"/></label></p>' }
523
523
 
524
524
  it "gives proper description" do
525
525
  have_field('Text field').description.should == "have field \"Text field\""
526
526
  end
527
527
 
528
+ it "gives proper description for a given value" do
529
+ have_field('Text field', with: 'some value').description.should == "have field \"Text field\" with value \"some value\""
530
+ end
531
+
528
532
  it "passes if there is such a field" do
529
533
  html.should have_field('Text field')
530
534
  end
531
535
 
536
+ it "passes if there is such a field with value" do
537
+ html.should have_field('Text field', with: 'some value')
538
+ end
539
+
532
540
  it "fails if there is no such field" do
533
541
  expect do
534
542
  html.should have_field('No such Field')
535
543
  end.to raise_error(/expected to find field "No such Field"/)
536
544
  end
545
+
546
+ it "fails if there is such field but with false value" do
547
+ expect do
548
+ html.should have_field('Text field', with: 'false value')
549
+ end.to raise_error(/expected to find field "Text field"/)
550
+ end
551
+
552
+ it "treats a given value as a string" do
553
+ class Foo
554
+ def to_s
555
+ "some value"
556
+ end
557
+ end
558
+ html.should have_field('Text field', with: Foo.new)
559
+ end
537
560
  end
538
561
 
539
562
  describe "have_checked_field matcher" do
@@ -1,7 +1,14 @@
1
1
  require 'spec_helper'
2
+ require "selenium-webdriver"
3
+
4
+ Capybara.register_driver :selenium_focus do |app|
5
+ profile = Selenium::WebDriver::Firefox::Profile.new
6
+ profile["focusmanager.testmode"] = true
7
+ Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
8
+ end
2
9
 
3
10
  module TestSessions
4
- Selenium = Capybara::Session.new(:selenium, TestApp)
11
+ Selenium = Capybara::Session.new(:selenium_focus, TestApp)
5
12
  end
6
13
 
7
14
  Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", :skip => [
@@ -24,7 +31,7 @@ describe Capybara::Session do
24
31
 
25
32
  describe '#mode' do
26
33
  it "should remember the mode" do
27
- @session.mode.should == :selenium
34
+ @session.mode.should == :selenium_focus
28
35
  end
29
36
  end
30
37
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ Capybara.register_driver :selenium_chrome do |app|
4
+ args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
5
+ Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
6
+ end
7
+
8
+ class ChromeTestApp < TestApp
9
+ # Object.id is different from the TestApp used in firefox session so
10
+ # a new Capybar::Server instance will get launched for chrome testing
11
+ end
12
+
13
+ module TestSessions
14
+ Chrome = Capybara::Session.new(:selenium_chrome, ChromeTestApp)
15
+ end
16
+
17
+ Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", :skip => [
18
+ :response_headers,
19
+ :status_code,
20
+ :trigger
21
+ ]
data/spec/server_spec.rb CHANGED
@@ -18,13 +18,21 @@ describe Capybara::Server do
18
18
  end
19
19
 
20
20
  it "should bind to the specified host" do
21
- Capybara.server_host = '0.0.0.0'
21
+ begin
22
+ app = proc { |env| [200, {}, ['Hello Server!']] }
22
23
 
23
- app = proc { |env| [200, {}, ["Hello Server!"]]}
24
- server = Capybara::Server.new(app).boot
25
- server.host.should == '0.0.0.0'
24
+ Capybara.server_host = '127.0.0.1'
25
+ server = Capybara::Server.new(app).boot
26
+ res = Net::HTTP.get(URI("http://127.0.0.1:#{server.port}"))
27
+ expect(res).to eq('Hello Server!')
26
28
 
27
- Capybara.server_host = nil
29
+ Capybara.server_host = '0.0.0.0'
30
+ server = Capybara::Server.new(app).boot
31
+ res = Net::HTTP.get(URI("http://127.0.0.1:#{server.port}"))
32
+ expect(res).to eq('Hello Server!')
33
+ ensure
34
+ Capybara.server_host = nil
35
+ end
28
36
  end
29
37
 
30
38
  it "should use specified port" do
data.tar.gz.sig CHANGED
Binary file