btakita-screw-unit-server 0.3.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +44 -1
- data/README.markdown +17 -5
- data/Rakefile +28 -55
- data/VERSION.yml +5 -0
- data/bin/screw_unit_server +8 -4
- data/core/CHANGES +10 -0
- data/core/EXAMPLE.html +4 -4
- data/core/README.markdown +7 -7
- data/core/example/models/man.js +2 -2
- data/core/example/spec/suite.html +1 -1
- data/core/lib/jquery-1.3.2.js +4376 -0
- data/core/lib/jquery.fn.js +2 -1
- data/core/lib/jquery.print.js +13 -12
- data/core/lib/screw.behaviors.js +11 -9
- data/core/lib/screw.builder.js +26 -11
- data/core/lib/screw.css +2 -2
- data/core/lib/screw.events.js +11 -4
- data/core/lib/screw.matchers.js +192 -13
- data/core/spec/behaviors_spec.js +11 -1
- data/core/spec/matchers_spec.js +288 -9
- data/core/spec/print_spec.js +47 -8
- data/core/spec/suite.html +2 -1
- data/core/spec/with_screw_context_spec.js +9 -0
- data/lib/screw_unit.rb +12 -17
- data/spec/functional/functional_spec.rb +15 -4
- data/spec/functional/functional_spec_helper.rb +22 -35
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/spec_suite.rb +0 -1
- data/standalone.ru +3 -0
- data/vendor/js-test-core/CHANGES +22 -0
- data/vendor/js-test-core/README +4 -10
- data/vendor/js-test-core/Rakefile +2 -1
- data/vendor/js-test-core/{spec/example_core/JsTestCore.css → bin/js-test-client} +0 -0
- data/vendor/js-test-core/bin/js-test-server +6 -0
- data/vendor/js-test-core/lib/js_test_core.rb +27 -19
- data/vendor/js-test-core/lib/js_test_core/app.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +125 -36
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +65 -0
- data/vendor/js-test-core/lib/js_test_core/representations.rb +13 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +25 -0
- data/vendor/js-test-core/lib/js_test_core/representations/frameworks.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
- data/vendor/js-test-core/lib/js_test_core/representations/suite.html.rb +57 -0
- data/vendor/js-test-core/lib/js_test_core/representations/suites.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/representations/suites/screw_unit.html.rb +81 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +12 -8
- data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
- data/vendor/js-test-core/lib/js_test_core/resources/file.rb +43 -13
- data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +28 -0
- data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
- data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +51 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +7 -54
- data/vendor/js-test-core/lib/js_test_core/server.rb +65 -92
- data/vendor/js-test-core/public/js_test_server.js +541 -0
- data/vendor/js-test-core/spec/{example_core/JsTestCore.js → example_framework/JsTestCore.css} +0 -0
- data/vendor/js-test-core/spec/{example_public/favicon.ico → example_framework/JsTestCore.js} +0 -0
- data/vendor/js-test-core/spec/{example_public/robots.txt → example_framework/subdir/SubDirFile.js} +0 -0
- data/vendor/js-test-core/spec/example_root/favicon.ico +0 -0
- data/vendor/js-test-core/spec/{example_public → example_root}/javascripts/foo.js +1 -1
- data/vendor/js-test-core/spec/example_root/javascripts/large_file.js +59 -0
- data/vendor/js-test-core/spec/example_root/javascripts/subdir/bar.js +1 -0
- data/vendor/js-test-core/spec/example_root/robots.txt +0 -0
- data/vendor/js-test-core/spec/{example_public → example_root}/stylesheets/example.css +0 -0
- data/vendor/js-test-core/spec/example_spec/custom_dir_and_suite/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/custom_suite.html +8 -0
- data/vendor/js-test-core/spec/example_spec/failing_spec.js +7 -0
- data/vendor/js-test-core/spec/example_spec/foo/failing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/foo/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/example_spec/passing_spec.js +8 -0
- data/vendor/js-test-core/spec/functional/functional_spec.rb +25 -0
- data/vendor/js-test-core/spec/functional/functional_spec_helper.rb +42 -0
- data/vendor/js-test-core/spec/functional/functional_spec_server_starter.rb +77 -0
- data/vendor/js-test-core/spec/functional_suite.rb +10 -0
- data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
- data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
- data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +16 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/spec_suite.rb +2 -1
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +153 -94
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +50 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +61 -68
- data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +149 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +14 -89
- data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +41 -106
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +19 -114
- data/vendor/js-test-core/standalone.ru +1 -0
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +77 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +5 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +142 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource/path.rb +24 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +276 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
- data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/syntax_ideas.txt +34 -0
- metadata +145 -130
- data/core/TODO +0 -2
- data/core/lib/jquery-1.2.3.js +0 -3408
- data/core/lib/screw.assets.js +0 -36
- data/core/lib/screw.server.js +0 -21
- data/lib/screw_unit/resources.rb +0 -2
- data/lib/screw_unit/resources/spec.rb +0 -37
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -43
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +0 -43
- data/spec/unit/unit_spec_helper.rb +0 -120
- data/spec/unit_suite.rb +0 -10
- data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
- data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -52
- data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -15
- data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +0 -15
- data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +0 -75
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +0 -24
- data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +0 -19
- data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
- data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
- data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
- data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
- data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -42
- data/vendor/js-test-core/spec/example_specs/failing_spec.js +0 -5
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +0 -6
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +0 -6
- data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
- data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -26
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +0 -24
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +0 -197
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +0 -94
- data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -44
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -92
@@ -1,79 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
module Resources
|
5
|
-
module Specs
|
6
|
-
describe SpecDir do
|
7
|
-
attr_reader :dir, :absolute_path, :relative_path
|
8
|
-
before do
|
9
|
-
@absolute_path = spec_root_path
|
10
|
-
@relative_path = "/specs"
|
11
|
-
@dir = Resources::Specs::SpecDir.new(absolute_path, relative_path)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "has an absolute path" do
|
15
|
-
dir.absolute_path.should == absolute_path
|
16
|
-
end
|
17
|
-
|
18
|
-
it "has a relative path" do
|
19
|
-
dir.relative_path.should == relative_path
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#locate when passed the name with an extension" do
|
23
|
-
it "when file exists, returns a Resources::File representing it" do
|
24
|
-
file = dir.locate("failing_spec.js")
|
25
|
-
file.relative_path.should == "/specs/failing_spec.js"
|
26
|
-
file.absolute_path.should == "#{spec_root_path}/failing_spec.js"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "when file does not exist, raises error" do
|
30
|
-
lambda { dir.locate("nonexistent.js") }.should raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#locate when passed a name without an extension" do
|
35
|
-
it "when name corresponds to a subdirectory, returns a DirectoryRunner for the directory" do
|
36
|
-
subdir = dir.locate("foo")
|
37
|
-
subdir.should == spec_dir("/foo")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "when name does not correspond to a .js file or directory, raises an error" do
|
41
|
-
lambda do
|
42
|
-
dir.locate("nonexistent")
|
43
|
-
end.should raise_error
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "#get" do
|
48
|
-
attr_reader :request, :response
|
49
|
-
before do
|
50
|
-
@request = Rack::Request.new( Rack::MockRequest.env_for('/core') )
|
51
|
-
@response = Rack::Response.new
|
52
|
-
end
|
53
|
-
|
54
|
-
it "raises NotImplementedError" do
|
55
|
-
lambda do
|
56
|
-
dir.get(request, response)
|
57
|
-
end.should raise_error(NotImplementedError)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "can be overridden from a Module without needing to redefine the #get method" do
|
61
|
-
spec_dir_class = Resources::Specs::SpecDir.clone
|
62
|
-
mod = Module.new do
|
63
|
-
def get(request, response)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
spec_dir_class.class_eval do
|
67
|
-
include mod
|
68
|
-
end
|
69
|
-
@dir = spec_dir_class.new(absolute_path, relative_path)
|
70
|
-
|
71
|
-
lambda do
|
72
|
-
dir.get(request, response)
|
73
|
-
end.should_not raise_error
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
module Resources
|
5
|
-
module Specs
|
6
|
-
describe SpecFile do
|
7
|
-
attr_reader :file, :absolute_path, :relative_path, :request, :response
|
8
|
-
before do
|
9
|
-
@absolute_path = "#{spec_root_path}/failing_spec.js"
|
10
|
-
@relative_path = "/specs/failing_spec.js"
|
11
|
-
@file = Resources::Specs::SpecFile.new(absolute_path, relative_path)
|
12
|
-
@request = Rack::Request.new( Rack::MockRequest.env_for(relative_path) )
|
13
|
-
@response = Rack::Response.new
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#get" do
|
17
|
-
it "raises NotImplementedError" do
|
18
|
-
lambda do
|
19
|
-
file.get(request, response)
|
20
|
-
end.should raise_error(NotImplementedError)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "can be overridden from a Module without needing to redefine the #get method" do
|
24
|
-
spec_file_class = Resources::Specs::SpecFile.clone
|
25
|
-
mod = Module.new do
|
26
|
-
def get(request, response)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
spec_file_class.class_eval do
|
30
|
-
include mod
|
31
|
-
end
|
32
|
-
@file = spec_file_class.new(absolute_path, relative_path)
|
33
|
-
|
34
|
-
lambda do
|
35
|
-
file.get(request, response)
|
36
|
-
end.should_not raise_error
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
module Resources
|
5
|
-
describe SuiteFinish do
|
6
|
-
attr_reader :stdout, :suite_finish, :suite
|
7
|
-
before do
|
8
|
-
@stdout = StringIO.new
|
9
|
-
SuiteFinish.const_set(:STDOUT, stdout)
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
SuiteFinish.__send__(:remove_const, :STDOUT)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".post" do
|
17
|
-
describe "when Suite#id == 'user'" do
|
18
|
-
before do
|
19
|
-
@suite = Suite.new('user')
|
20
|
-
@suite_finish = SuiteFinish.new(suite)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "writes the body of the request to stdout" do
|
24
|
-
body = "The text in the POST body"
|
25
|
-
request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
|
26
|
-
request.body.string.should == "text=#{body}"
|
27
|
-
response = Rack::Response.new
|
28
|
-
|
29
|
-
suite_finish.post(request, response)
|
30
|
-
stdout.string.should == "#{body}\n"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "sets the Content-Length to be 0" do
|
34
|
-
request = Rack::Request.new('rack.input' => StringIO.new(""))
|
35
|
-
response = Rack::Response.new
|
36
|
-
|
37
|
-
response.headers["Content-Length"].should be_nil
|
38
|
-
suite_finish.post(request, response)
|
39
|
-
response.headers["Content-Length"].should == "0"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "when Suite#id is not 'user'" do
|
44
|
-
attr_reader :request, :response, :runner, :suite_id, :driver
|
45
|
-
before do
|
46
|
-
runner_request = Rack::Request.new( Rack::MockRequest.env_for('/runners/firefox') )
|
47
|
-
runner_response = Rack::Response.new
|
48
|
-
@suite_id = '12345'
|
49
|
-
@driver = "Selenium Driver"
|
50
|
-
stub(Selenium::SeleniumDriver).new('localhost', 4444, '*firefox', 'http://0.0.0.0:8080') do
|
51
|
-
driver
|
52
|
-
end
|
53
|
-
stub(driver).start
|
54
|
-
stub(driver).open
|
55
|
-
stub(driver).session_id {suite_id}
|
56
|
-
stub(Thread).start.yields
|
57
|
-
Thread.current[:connection] = connection
|
58
|
-
|
59
|
-
@runner = Runners::FirefoxRunner.new
|
60
|
-
runner.post(runner_request, runner_response)
|
61
|
-
|
62
|
-
@suite = Suite.new(suite_id)
|
63
|
-
@suite_finish = SuiteFinish.new(suite)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "resumes the FirefoxRunner" do
|
67
|
-
body = "The text in the POST body"
|
68
|
-
request = Rack::Request.new({'rack.input' => StringIO.new("text=#{body}")})
|
69
|
-
response = Rack::Response.new
|
70
|
-
mock.proxy(Runners::FirefoxRunner).resume(suite_id, body)
|
71
|
-
mock(driver).stop
|
72
|
-
stub(connection).send_data.once
|
73
|
-
stub(connection).close_connection.once
|
74
|
-
|
75
|
-
suite_finish.post(request, response)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "sets the Content-Length to be 0" do
|
79
|
-
request = Rack::Request.new('rack.input' => StringIO.new(""))
|
80
|
-
response = Rack::Response.new
|
81
|
-
stub(Runners::FirefoxRunner).resume
|
82
|
-
stub(driver).stop
|
83
|
-
stub(connection).send_data
|
84
|
-
stub(connection).close_connection
|
85
|
-
|
86
|
-
response.headers["Content-Length"].should be_nil
|
87
|
-
suite_finish.post(request, response)
|
88
|
-
response.headers["Content-Length"].should == "0"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
module Resources
|
5
|
-
describe Suite do
|
6
|
-
attr_reader :stdout
|
7
|
-
before do
|
8
|
-
@stdout = StringIO.new
|
9
|
-
Suite.const_set(:STDOUT, stdout)
|
10
|
-
end
|
11
|
-
|
12
|
-
after do
|
13
|
-
Suite.__send__(:remove_const, :STDOUT)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".locate" do
|
17
|
-
it "when passed an identifier, returns an instance of Suite with the identifier" do
|
18
|
-
instance = Suite.locate('foobar')
|
19
|
-
instance.class.should == Suite
|
20
|
-
instance.id.should == 'foobar'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#locate" do
|
25
|
-
attr_reader :suite
|
26
|
-
before do
|
27
|
-
@suite = Suite.new('foobar')
|
28
|
-
end
|
29
|
-
|
30
|
-
it "when passed 'finish', returns a SuiteFinish that has access to the suite" do
|
31
|
-
suite_finish = suite.locate('finish')
|
32
|
-
suite_finish.class.should == SuiteFinish
|
33
|
-
suite_finish.suite.should == suite
|
34
|
-
end
|
35
|
-
|
36
|
-
it "when not passed 'finish', raises ArgumentError" do
|
37
|
-
lambda do
|
38
|
-
suite.locate('invalid')
|
39
|
-
end.should raise_error(ArgumentError, "Invalid path: invalid")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,92 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module Thin
|
4
|
-
describe JsTestCoreConnection do
|
5
|
-
describe "#process" do
|
6
|
-
attr_reader :connection, :result
|
7
|
-
before do
|
8
|
-
@connection = JsTestCoreConnection.new('signature')
|
9
|
-
stub(connection).socket_address {'0.0.0.0'}
|
10
|
-
|
11
|
-
@result = ""
|
12
|
-
stub(EventMachine).send_data do |signature, data, data_length|
|
13
|
-
result << data
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "and the call is successful" do
|
18
|
-
describe "and the body is not empty" do
|
19
|
-
before do
|
20
|
-
mock(app = Object.new).call(is_a(Hash)) do
|
21
|
-
[200, {}, 'The Body']
|
22
|
-
end
|
23
|
-
connection.app = app
|
24
|
-
end
|
25
|
-
|
26
|
-
it "sends the response to the socket and closes the connection" do
|
27
|
-
mock(connection).close_connection_after_writing
|
28
|
-
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
29
|
-
result.should include("The Body")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "and the body is empty" do
|
34
|
-
describe "and the Content-Length header is 0" do
|
35
|
-
before do
|
36
|
-
mock(app = Object.new).call(is_a(Hash)) do
|
37
|
-
[200, {"Content-Length" => '0'}, []]
|
38
|
-
end
|
39
|
-
connection.app = app
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sends the response to the socket and closes the connection" do
|
43
|
-
mock(connection).close_connection_after_writing
|
44
|
-
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "and the Content-Length header is > 0" do
|
49
|
-
before do
|
50
|
-
mock(app = Object.new).call(is_a(Hash)) do
|
51
|
-
[200, {"Content-Length" => '55'}, []]
|
52
|
-
end
|
53
|
-
connection.app = app
|
54
|
-
end
|
55
|
-
|
56
|
-
it "keeps the connection open" do
|
57
|
-
dont_allow(connection).close_connection_after_writing
|
58
|
-
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "and the Content-Length header is not passed in" do
|
63
|
-
before do
|
64
|
-
mock(app = Object.new).call(is_a(Hash)) do
|
65
|
-
[200, {}, []]
|
66
|
-
end
|
67
|
-
connection.app = app
|
68
|
-
end
|
69
|
-
|
70
|
-
it "keeps the connection open" do
|
71
|
-
dont_allow(connection).close_connection_after_writing
|
72
|
-
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "and the call raises an error" do
|
79
|
-
it "logs the error and closes the connection" do
|
80
|
-
mock(app = Object.new).call(is_a(Hash)) do
|
81
|
-
raise "An Error"
|
82
|
-
end
|
83
|
-
connection.app = app
|
84
|
-
mock(connection).log(anything).at_least(1)
|
85
|
-
mock(connection).close_connection
|
86
|
-
|
87
|
-
connection.receive_data "GET /specs HTTP/1.1\r\nHost: _\r\n\r\n"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|