coolerator.vision 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/.screwrc +15 -0
- data/VERSION +1 -1
- data/coolerator.vision.gemspec +46 -3
- data/public/javascripts/vendor/coolerator/coolerator.base.js +1 -0
- data/public/javascripts/vendor/coolerator/coolerator.filter.js +1 -1
- data/public/javascripts/vendor/coolerator/coolerator.module.js +5 -1
- data/public/javascripts/vendor/coolerator/coolerator.remote.js +7 -2
- data/public/javascripts/vendor/coolerator/coolerator.view.js +38 -18
- data/script/pair +61 -0
- data/spec/javascripts/support/spec_helper.js +8 -0
- data/spec/javascripts/vendor/coolerator/coolerator.base_spec.js +9 -0
- data/spec/javascripts/vendor/coolerator/coolerator.filter_spec.js +9 -0
- data/spec/javascripts/vendor/coolerator/coolerator.module_spec.js +9 -0
- data/spec/javascripts/vendor/coolerator/coolerator.registrar_spec.js +9 -0
- data/spec/javascripts/vendor/coolerator/coolerator.remote_spec.js +9 -0
- data/spec/javascripts/vendor/coolerator/coolerator.view_spec.js +87 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit.rb +19 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/array_extension.rb +10 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/asset_location.rb +67 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/asset_manager.rb +68 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/configuration.rb +91 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/dispatcher.rb +41 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/js_file.rb +60 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources.rb +9 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/dir.rb +24 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/file.rb +40 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/file_not_found.rb +24 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/root.rb +27 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/spec_dir.rb +30 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/spec_runner.rb +88 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/streaming_spec_runner.rb +27 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/resources/suite_completion.rb +25 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/server.rb +43 -0
- data/spec/support/vendor/screw-unit/lib/screw_unit/string_extension.rb +9 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/array_extension_spec.rb +15 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/asset_location_spec.rb +31 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/asset_manager_spec.rb +92 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/configuration_spec.rb +51 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/dispatcher_spec.rb +60 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/js_file_spec.rb +24 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/dir_spec.rb +68 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/file_spec.rb +97 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/root_spec.rb +48 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/spec_dir_spec.rb +52 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/spec_suite_spec.rb +46 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/resources/suite_completion_spec.rb +68 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit/server_spec.rb +15 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit_spec_helper.rb +13 -0
- data/spec/support/vendor/screw-unit/spec/screw_unit_spec_suite.rb +4 -0
- metadata +45 -2
@@ -0,0 +1,60 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
describe Dispatcher do
|
5
|
+
attr_reader :dispatcher, :locator_1, :locator_2
|
6
|
+
before do
|
7
|
+
@locator_1 = Object.new
|
8
|
+
@locator_2 = Object.new
|
9
|
+
@dispatcher = Dispatcher.new(configuration)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#locate_resource(path)" do
|
13
|
+
context "when there are #resource_locators" do
|
14
|
+
def configuration
|
15
|
+
return @configuration if @configuration
|
16
|
+
@configuration = Configuration.new
|
17
|
+
@configuration.add_resource_locator(locator_1)
|
18
|
+
@configuration.add_resource_locator(locator_2)
|
19
|
+
@configuration
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when one of the custom locators returns a resource" do
|
23
|
+
attr_reader :resource
|
24
|
+
before do
|
25
|
+
@resource = Object.new
|
26
|
+
mock(locator_2).locate_resource("/foo").ordered { nil }
|
27
|
+
mock(locator_1).locate_resource("/foo").ordered { resource }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns that resource" do
|
31
|
+
dispatcher.locate_resource("/foo").should == resource
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when no custom locators return a resource" do
|
36
|
+
before do
|
37
|
+
mock(locator_2).locate_resource("/foo").ordered { nil }
|
38
|
+
mock(locator_1).locate_resource("/foo").ordered { nil }
|
39
|
+
end
|
40
|
+
|
41
|
+
it "performs the normal dispatch starting at Resources::Root" do
|
42
|
+
mock.instance_of(Resources::Root).locate("foo")
|
43
|
+
dispatcher.locate_resource("/foo")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when there are no #resource_locators" do
|
49
|
+
def configuration
|
50
|
+
@configuration ||= Configuration.new
|
51
|
+
end
|
52
|
+
|
53
|
+
it "performs the normal dispatch starting at Resources::Root" do
|
54
|
+
mock.instance_of(Resources::Root).locate("foo")
|
55
|
+
dispatcher.locate_resource("/foo")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
describe JsFile do
|
5
|
+
attr_reader :js_file, :dir
|
6
|
+
|
7
|
+
before do
|
8
|
+
@dir = File.expand_path(File.dirname(__FILE__))
|
9
|
+
asset_manager = Configuration.new.asset_manager
|
10
|
+
asset_manager.add_js_location("/implementations", "#{dir}/file_system_fixtures_for_asset_manager_specs/dir_3")
|
11
|
+
@js_file = JsFile.new("#{dir}/file_system_fixtures_for_asset_manager_specs/dir_1/1.js", asset_manager)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#require_declarations" do
|
15
|
+
it "returns a relative or global RequireDeclaration for every Sprockets-style require declaration in the file" do
|
16
|
+
require_declarations = js_file.require_declarations
|
17
|
+
require_declarations.size.should == 3
|
18
|
+
require_declarations[0].js_file.physical_path.should == "#{dir}/file_system_fixtures_for_asset_manager_specs/dir_1/subdir_1/4.js"
|
19
|
+
require_declarations[1].js_file.physical_path.should == "#{dir}/file_system_fixtures_for_asset_manager_specs/dir_1/7.js"
|
20
|
+
require_declarations[2].js_file.physical_path.should == "#{dir}/file_system_fixtures_for_asset_manager_specs/dir_3/3.js"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe Dir do
|
6
|
+
attr_reader :dir, :asset_manager
|
7
|
+
|
8
|
+
before do
|
9
|
+
spec_file_dir = ::File.expand_path(::File.dirname(__FILE__))
|
10
|
+
@asset_manager = Configuration.new.asset_manager
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#locate" do
|
14
|
+
before do
|
15
|
+
asset_manager.add_location("/x", "#{::File.expand_path(::File.dirname(__FILE__))}/file_system_fixtures")
|
16
|
+
@dir = Dir.new("/x", asset_manager)
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when the string names a file in the directory" do
|
20
|
+
it "returns a File resource with the appropriate virtual path and the same AssetManager" do
|
21
|
+
file = dir.locate("foo.js")
|
22
|
+
file.class.should == Resources::File
|
23
|
+
file.virtual_path.should == "/x/foo.js"
|
24
|
+
file.asset_manager.should == asset_manager
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the string names a subdirectory in the directory" do
|
29
|
+
it "returns a Dir resource with the appropriate absolute path and the same AssetManeger" do
|
30
|
+
subdir = dir.locate("specs")
|
31
|
+
subdir.class.should == Resources::Dir
|
32
|
+
subdir.virtual_path.should == "/x/specs"
|
33
|
+
subdir.asset_manager.should == asset_manager
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when the string names a file that doesn't exist" do
|
38
|
+
it "returns a FileNotFound resource with the relative path" do
|
39
|
+
not_found = dir.locate("bogus")
|
40
|
+
not_found.class.should == FileNotFound
|
41
|
+
not_found.virtual_path.should == "/x/bogus"
|
42
|
+
|
43
|
+
not_found = Dir.new("/", asset_manager).locate("bogus")
|
44
|
+
not_found.class.should == FileNotFound
|
45
|
+
not_found.virtual_path.should == "/bogus"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#glob" do
|
51
|
+
before do
|
52
|
+
@dir = Dir.new("/foo", asset_manager)
|
53
|
+
absolute_dir = ::File.expand_path(::File.dirname(__FILE__))
|
54
|
+
asset_manager.add_location("/foo/bar", "#{absolute_dir}/file_system_fixtures/code_under_test")
|
55
|
+
asset_manager.add_location("/foo/baz", "#{absolute_dir}/file_system_fixtures/specs")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "returns File resources with the correct relative paths for all files matching the pattern" do
|
59
|
+
globbed_file_resources = dir.glob("/**/*.js")
|
60
|
+
globbed_file_resources.map {|fr| fr.virtual_path}.should == ["/foo/baz/foo_spec.js", "/foo/baz/subsuite/bar_spec.js", "/foo/bar/code_under_test.js"]
|
61
|
+
globbed_file_resources.each do |fr|
|
62
|
+
fr.asset_manager.should == asset_manager
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe File do
|
6
|
+
attr_reader :dir, :file, :asset_manager
|
7
|
+
|
8
|
+
before do
|
9
|
+
@dir = ::File.expand_path(::File.dirname(__FILE__))
|
10
|
+
@asset_manager = Configuration.new.asset_manager
|
11
|
+
asset_manager.add_js_location("/", "#{dir}/file_system_fixtures")
|
12
|
+
@file = File.new(virtual_path, asset_manager)
|
13
|
+
end
|
14
|
+
|
15
|
+
def virtual_path
|
16
|
+
"/foo.js"
|
17
|
+
end
|
18
|
+
|
19
|
+
def physical_path
|
20
|
+
asset_manager.physicalize_path(virtual_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#get" do
|
24
|
+
attr_reader :response_code, :headers, :body
|
25
|
+
|
26
|
+
before do
|
27
|
+
::File.exist?(physical_path).should be_true
|
28
|
+
@response_code, @headers, @body = file.get
|
29
|
+
end
|
30
|
+
|
31
|
+
it "returns 200 as the response code" do
|
32
|
+
response_code.should == 200
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returs the file's mtime as the 'Last-Modified' header" do
|
36
|
+
headers['Last-Modified'].should == ::File.mtime(physical_path).httpdate
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns the contents of the file as the response body" do
|
40
|
+
response_body = ""
|
41
|
+
body.each { |chunk| response_body.concat(chunk) }
|
42
|
+
response_body.should == ::File.read(physical_path)
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the file has a .js extension" do
|
46
|
+
before do
|
47
|
+
virtual_path.should =~ /\.js$/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has a Content-Type header of 'application/javascript'" do
|
51
|
+
headers['Content-Type'].should == "application/javascript"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when the file has a .css extension" do
|
56
|
+
def virtual_path
|
57
|
+
"/foo.css"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "has a Content-Type header of 'text/css'" do
|
61
|
+
headers['Content-Type'].should == "text/css"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when the file has a .png extension" do
|
66
|
+
def virtual_path
|
67
|
+
"/foo.png"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has a Content-Type header of 'text/png'" do
|
71
|
+
headers['Content-Type'].should == "image/png"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when the file has a .jpg extension" do
|
76
|
+
def virtual_path
|
77
|
+
"/foo.jpg"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "has a Content-Type header of 'image/jpeg'" do
|
81
|
+
headers['Content-Type'].should == "image/jpeg"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when the file has a .jpeg extension" do
|
86
|
+
def virtual_path
|
87
|
+
"/foo.jpeg"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "has a Content-Type header of 'image/jpeg'" do
|
91
|
+
headers['Content-Type'].should == "image/jpeg"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe Root do
|
6
|
+
attr_reader :root, :options, :configuration
|
7
|
+
before do
|
8
|
+
dir = ::File.dirname(__FILE__)
|
9
|
+
@configuration = Configuration.new
|
10
|
+
@root = Root.new(configuration)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#locate" do
|
14
|
+
context "when called with 'specs'" do
|
15
|
+
it "returns a SpecDir resource with a #virtual_path of '/specs' and the same AssetManager" do
|
16
|
+
specs_dir = root.locate('specs')
|
17
|
+
specs_dir.class.should == Resources::SpecDir
|
18
|
+
specs_dir.virtual_path.should == "/specs"
|
19
|
+
specs_dir.asset_manager.should == configuration.asset_manager
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when called with 'complete'" do
|
24
|
+
|
25
|
+
context "when #selenium_mode? is true on the given configuration" do
|
26
|
+
before do
|
27
|
+
configuration.selenium_mode
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns a SuiteCompletion with #kill_server_on_completion? set to true" do
|
31
|
+
suite_completion = root.locate('complete')
|
32
|
+
suite_completion.class.should == Resources::SuiteCompletion
|
33
|
+
suite_completion.kill_server_on_completion?.should be_true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when #selenium_mode? is false on the given configuration" do
|
38
|
+
it "returns a SuiteCompletion with #kill_server_on_completion? set to false" do
|
39
|
+
suite_completion = root.locate('complete')
|
40
|
+
suite_completion.class.should == Resources::SuiteCompletion
|
41
|
+
suite_completion.kill_server_on_completion?.should be_false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe SpecDir do
|
6
|
+
attr_reader :spec_dir, :asset_manager
|
7
|
+
|
8
|
+
before do
|
9
|
+
dir = ::File.expand_path(::File.dirname(__FILE__))
|
10
|
+
@asset_manager = Configuration.new.asset_manager
|
11
|
+
asset_manager.add_js_location("/specs", "#{dir}/file_system_fixtures/specs")
|
12
|
+
@spec_dir = SpecDir.new("/specs", asset_manager)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#locate" do
|
16
|
+
describe "when called with the name of a directory" do
|
17
|
+
it "returns a SpecDir for that directory" do
|
18
|
+
spec_subdir = spec_dir.locate("subsuite")
|
19
|
+
spec_subdir.class.should == SpecDir
|
20
|
+
spec_subdir.virtual_path.should == "/specs/subsuite"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "when called with the name of a .js file excluding the extension" do
|
25
|
+
it "returns a SpecRunner with the .js file as its only spec_file_resource" do
|
26
|
+
spec_suite = spec_dir.locate("foo_spec")
|
27
|
+
spec_suite.class.should == SpecRunner
|
28
|
+
spec_file_resources = spec_suite.spec_file_resources
|
29
|
+
spec_file_resources.length.should == 1
|
30
|
+
spec_file_resources.first.virtual_path.should == "/specs/foo_spec.js"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "when called with the name of a .js file including the extension" do
|
35
|
+
it "returns a normal File resource for the File" do
|
36
|
+
spec_file = spec_dir.locate("foo_spec.js")
|
37
|
+
spec_file.class.should == File
|
38
|
+
spec_file.virtual_path.should == "/specs/foo_spec.js"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#get" do
|
44
|
+
it "returns the results of #get called on a SpecRunner instantiated with all /**/*.js files in the directory" do
|
45
|
+
spec_files = spec_dir.glob("/**/*.js")
|
46
|
+
spec_files.should_not be_empty
|
47
|
+
spec_dir.get.should == SpecRunner.new(spec_files, asset_manager).get
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe SpecRunner do
|
6
|
+
attr_reader :dir, :spec_file_resources, :spec_suite, :asset_manager
|
7
|
+
|
8
|
+
before do
|
9
|
+
@dir = ::File.expand_path(::File.dirname(__FILE__))
|
10
|
+
@asset_manager = Configuration.new.asset_manager
|
11
|
+
asset_manager.add_location("/specs", "#{dir}/file_system_fixtures/specs")
|
12
|
+
@spec_file_resources = Dir.new("/specs", asset_manager).glob("**/*.js")
|
13
|
+
@spec_suite = SpecRunner.new(spec_file_resources, asset_manager)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#get" do
|
17
|
+
attr_reader :response_code, :headers, :content
|
18
|
+
before do
|
19
|
+
@response_code, @headers, @content = spec_suite.get
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a response code of 200" do
|
23
|
+
response_code.should == 200
|
24
|
+
end
|
25
|
+
|
26
|
+
it "returns a Content-Type header of 'text/html'" do
|
27
|
+
headers['Content-Type'].should == "text/html"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "includes the relative paths of all the screw unit core files" do
|
31
|
+
Dir.new("/screw_unit_core", asset_manager).glob("/**/*.js").each do |core_file_resource|
|
32
|
+
expected_include_tag = %{<script type="text/javascript" src="#{core_file_resource.virtual_path}"></script>}
|
33
|
+
content.should match(/#{expected_include_tag}/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "includes the relative paths of all the scripts files with which it was initialized" do
|
38
|
+
spec_file_resources.each do |spec_file_resource|
|
39
|
+
expected_include_tag = %{<script type="text/javascript" src="#{spec_file_resource.virtual_path}"></script>}
|
40
|
+
content.should match(/#{expected_include_tag}/)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../screw_unit_spec_helper"
|
2
|
+
|
3
|
+
module ScrewUnit
|
4
|
+
module Resources
|
5
|
+
describe SuiteCompletion do
|
6
|
+
attr_reader :suite_completion, :mock_request
|
7
|
+
|
8
|
+
describe "#post" do
|
9
|
+
before do
|
10
|
+
$exit_status = nil
|
11
|
+
$thin_server = Object.new
|
12
|
+
@mock_request = Object.new
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when #kill_server_on_completion? is true" do
|
16
|
+
before do
|
17
|
+
@suite_completion = SuiteCompletion.new(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when the request body is 'success'" do
|
21
|
+
before do
|
22
|
+
stub(mock_request).body { StringIO.new("success") }
|
23
|
+
end
|
24
|
+
|
25
|
+
it "sends a success response and sets the $exit_status to 0" do
|
26
|
+
status, headers, body = suite_completion.post(mock_request)
|
27
|
+
status.should == 200
|
28
|
+
headers.should == {}
|
29
|
+
body.should == "OK"
|
30
|
+
$exit_status.should == 0
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when the request body is anything else" do
|
35
|
+
before do
|
36
|
+
stub(suite_completion).puts
|
37
|
+
stub(mock_request).body { StringIO.new("failure") }
|
38
|
+
end
|
39
|
+
|
40
|
+
it "sends a success response and sets the $exit_status to 1" do
|
41
|
+
status, headers, body = suite_completion.post(mock_request)
|
42
|
+
status.should == 200
|
43
|
+
headers.should == {}
|
44
|
+
body.should == "OK"
|
45
|
+
$exit_status.should == 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when #kill_server_on_completion? is not true" do
|
51
|
+
before do
|
52
|
+
@suite_completion = SuiteCompletion.new(false)
|
53
|
+
stub(suite_completion).puts
|
54
|
+
stub(mock_request).body { StringIO.new("anything") }
|
55
|
+
end
|
56
|
+
|
57
|
+
it "sends a success response and does not change $exit_status" do
|
58
|
+
status, headers, body = suite_completion.post(mock_request)
|
59
|
+
status.should == 200
|
60
|
+
headers.should == {}
|
61
|
+
body.should == "OK"
|
62
|
+
$exit_status.should be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|