screw-unit-server 0.3.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +23 -1
- data/README.markdown +10 -3
- data/Rakefile +27 -55
- data/VERSION.yml +4 -0
- data/bin/screw_unit_server +14 -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 +13 -16
- data/lib/screw_unit/representations.rb +2 -0
- data/lib/screw_unit/representations/spec.html.rb +117 -0
- data/spec/functional/functional_spec.rb +14 -3
- data/spec/functional/functional_spec_helper.rb +22 -34
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +45 -20
- data/spec/unit/unit_spec_helper.rb +24 -93
- data/vendor/js-test-core/CHANGES +19 -0
- data/vendor/js-test-core/Rakefile +2 -1
- data/vendor/js-test-core/lib/js_test_core.rb +26 -10
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +97 -18
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +3 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/selenium/client/driver.rb +7 -0
- data/vendor/js-test-core/lib/js_test_core/extensions/time.rb +6 -0
- data/vendor/js-test-core/lib/js_test_core/models.rb +8 -0
- data/vendor/js-test-core/lib/js_test_core/models/selenium_session.rb +80 -0
- data/vendor/js-test-core/lib/js_test_core/representations.rb +11 -0
- data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +15 -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/spec.html.rb +24 -0
- data/vendor/js-test-core/lib/js_test_core/resources.rb +13 -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 +44 -14
- 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 +35 -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/selenium_session.rb +104 -0
- data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +63 -0
- data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +5 -56
- data/vendor/js-test-core/lib/js_test_core/selenium_server_configuration.rb +48 -0
- data/vendor/js-test-core/spec/example_core/subdir/SubDirFile.js +0 -0
- data/vendor/js-test-core/spec/example_public/javascripts/large_file.js +59 -0
- data/vendor/js-test-core/spec/example_public/javascripts/subdir/bar.js +1 -0
- data/vendor/js-test-core/spec/example_specs/custom_dir_and_suite/passing_spec.js +6 -0
- data/vendor/js-test-core/spec/example_specs/custom_suite.html +8 -0
- data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +1 -1
- data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +1 -1
- 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 +27 -0
- data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
- data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +140 -85
- data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +44 -0
- data/vendor/js-test-core/spec/unit/js_test_core/models/selenium_session_spec.rb +85 -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/selenium_session_spec.rb +362 -0
- data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +120 -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/selenium_server_configuration_spec.rb +49 -0
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -113
- data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +7 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +4 -0
- data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +135 -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 +231 -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
- metadata +143 -129
- 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/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/server.rb +0 -111
- 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/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/js_test_core/server_spec.rb +0 -131
- 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,131 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
|
2
|
-
|
3
|
-
module JsTestCore
|
4
|
-
describe Server do
|
5
|
-
attr_reader :result
|
6
|
-
|
7
|
-
before do
|
8
|
-
@result = ""
|
9
|
-
stub(EventMachine).send_data do |signature, data, data_length|
|
10
|
-
@result << data
|
11
|
-
end
|
12
|
-
stub(EventMachine).close_connection
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "HTTP GET" do
|
16
|
-
specify "'/core/JsTestCore.js', returns the contents of the file" do
|
17
|
-
response = get("/core/JsTestCore.js")
|
18
|
-
response.body.should == ::File.read("#{Server.core_path}/JsTestCore.js")
|
19
|
-
end
|
20
|
-
|
21
|
-
specify "'/stylesheets/example.css', returns the contents of the file" do
|
22
|
-
response = get("/stylesheets/example.css")
|
23
|
-
response.body.should == ::File.read("#{Server.public_path}/stylesheets/example.css")
|
24
|
-
end
|
25
|
-
|
26
|
-
specify "'/invalid/path', shows the full invalid path in the error message" do
|
27
|
-
lambda do
|
28
|
-
get("/invalid/path")
|
29
|
-
end.should raise_error(Exception, Regexp.new("/invalid/path"))
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe ".run" do
|
34
|
-
attr_reader :server_instance
|
35
|
-
before do
|
36
|
-
@server_instance = Server.instance
|
37
|
-
Server.instance = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "instantiates an instance of Server and starts a Rack Thin handler" do
|
41
|
-
host = DEFAULT_HOST
|
42
|
-
port = DEFAULT_PORT
|
43
|
-
|
44
|
-
mock(EventMachine).run.yields
|
45
|
-
mock(EventMachine).start_server(host, port, ::Thin::JsTestCoreConnection)
|
46
|
-
|
47
|
-
Server.run(spec_root_path, implementation_root_path, public_path)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "when passed a custom host and port, sets the host and port to the passed in value" do
|
51
|
-
host = 'foobar.com'
|
52
|
-
port = 80
|
53
|
-
|
54
|
-
mock(EventMachine).run.yields
|
55
|
-
mock(EventMachine).start_server(host, port, ::Thin::JsTestCoreConnection)
|
56
|
-
|
57
|
-
Server.run(spec_root_path, implementation_root_path, public_path, {:Host => host, :Port => port})
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe ".spec_root" do
|
62
|
-
it "returns the Dir " do
|
63
|
-
Server.spec_root_path.should == spec_root_path
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe ".spec_root_path" do
|
68
|
-
it "returns the absolute path of the specs root directory" do
|
69
|
-
Server.spec_root_path.should == spec_root_path
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe ".public_path" do
|
74
|
-
it "returns the expanded path of the public path" do
|
75
|
-
Server.public_path.should == public_path
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe ".core_path" do
|
80
|
-
it "returns the expanded path to the JsTestCore core directory" do
|
81
|
-
Server.core_path.should == core_path
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe ".implementation_root_path" do
|
86
|
-
it "returns the expanded path to the JsTestCore implementations directory" do
|
87
|
-
dir = ::File.dirname(__FILE__)
|
88
|
-
Server.implementation_root_path.should == implementation_root_path
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#call" do
|
93
|
-
describe "when there is an error" do
|
94
|
-
attr_reader :top_line_of_backtrace
|
95
|
-
before do
|
96
|
-
@top_line_of_backtrace = __LINE__ + 2
|
97
|
-
stub.instance_of(Resources::WebRoot).locate('somedir') do
|
98
|
-
raise "Foobar"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it "shows the full request path in the error message" do
|
103
|
-
lambda do
|
104
|
-
get('/somedir')
|
105
|
-
end.should raise_error(Exception, Regexp.new("/somedir"))
|
106
|
-
end
|
107
|
-
|
108
|
-
it "uses the backtrace from where the original error was raised" do
|
109
|
-
no_error = true
|
110
|
-
begin
|
111
|
-
get('/somedir')
|
112
|
-
rescue Exception => e
|
113
|
-
no_error = false
|
114
|
-
top_of_backtrace = e.backtrace.first.split(":")
|
115
|
-
backtrace_file = ::File.expand_path(top_of_backtrace[0])
|
116
|
-
backtrace_line = Integer(top_of_backtrace[1])
|
117
|
-
backtrace_file.should == __FILE__
|
118
|
-
backtrace_line.should == top_line_of_backtrace
|
119
|
-
end
|
120
|
-
raise "There should have been an error" if no_error
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "#root_url" do
|
126
|
-
it "returns the url of the site's root" do
|
127
|
-
server.root_url.should == "http://#{server.host}:#{server.port}"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
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
|