Skip to content
This repository
Newer
Older
100644 65 lines (58 sloc) 2.07 kb
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
1 require 'spec_helper'
259a38f2 » jferris
2012-07-08 Follow new capybara driver naming/module conventions
2 require 'capybara/webkit/connection'
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
3
259a38f2 » jferris
2012-07-08 Follow new capybara driver naming/module conventions
4 describe Capybara::Webkit::Connection do
b538721f » jferris
2013-03-20 wip
5 it "starts a Webkit session" do
61a6561d » mhoran
2012-11-16 Session is responsible for starting server
6 url = "http://#{@rack_server.host}:#{@rack_server.port}/"
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
7 connection.puts "Visit"
8 connection.puts 1
9 connection.puts url.to_s.bytesize
10 connection.print url
b538721f » jferris
2013-03-20 wip
11 puts 'about to gets'
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
12 connection.gets.should == "ok\n"
b538721f » jferris
2013-03-20 wip
13 puts 'first gets is a go'
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
14 connection.gets.should == "0\n"
15 connection.puts "Body"
16 connection.puts 0
17 connection.gets.should == "ok\n"
18 response_length = connection.gets.to_i
19 response = connection.read(response_length)
20 response.should include("Hey there")
21 end
22
ea06a1b5 » mhoran
2013-02-02 Forward stderr from server to stderr, drop stdout
23 it 'forwards stderr to the given IO object' do
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
24 io = StringIO.new
ea06a1b5 » mhoran
2013-02-02 Forward stderr from server to stderr, drop stdout
25 redirected_connection = Capybara::Webkit::Connection.new(:stderr => io)
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
26 script = 'console.log("hello world")'
2ceab4e5 » mhoran
2012-11-22 Forward stderr via Open3#popen3
27 redirected_connection.puts "EnableLogging"
28 redirected_connection.puts 0
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
29 redirected_connection.puts "Execute"
30 redirected_connection.puts 1
31 redirected_connection.puts script.to_s.bytesize
32 redirected_connection.print script
33 sleep(0.5)
ea06a1b5 » mhoran
2013-02-02 Forward stderr from server to stderr, drop stdout
34 io.string.should =~ /hello world $/
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
35 end
36
9bb7b93b » mhoran
2013-02-02 Don't forward stderr to nil
37 it 'does not forward stderr to nil' do
38 IO.should_not_receive(:copy_stream)
39 Capybara::Webkit::Connection.new(:stderr => nil)
40 end
41
a70b7c4a » mhoran
2013-02-06 Deprecate the stdout option for Connection
42 it 'prints a deprecation warning if the stdout option is used' do
43 Capybara::Webkit::Connection.any_instance.should_receive(:warn)
44 Capybara::Webkit::Connection.new(:stdout => nil)
45 end
46
47 it 'does not forward stdout to nil if the stdout option is used' do
48 Capybara::Webkit::Connection.any_instance.stub(:warn)
49 IO.should_not_receive(:copy_stream)
50 Capybara::Webkit::Connection.new(:stdout => nil)
51 end
9bb7b93b » mhoran
2013-02-02 Don't forward stderr to nil
52
259a38f2 » jferris
2012-07-08 Follow new capybara driver naming/module conventions
53 let(:connection) { Capybara::Webkit::Connection.new }
665e0fc7 » jferris
2012-05-04 Extract a Connection class for booting the server
54
55 before(:all) do
56 @app = lambda do |env|
57 body = "<html><body>Hey there</body></html>"
58 [200,
59 { 'Content-Type' => 'text/html', 'Content-Length' => body.size.to_s },
60 [body]]
61 end
62 @rack_server = Capybara::Server.new(@app)
63 @rack_server.boot
64 end
65 end
Something went wrong with that request. Please try again.