honkster-screw-unit-server 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/CHANGES +48 -0
  2. data/README.markdown +359 -0
  3. data/Rakefile +43 -0
  4. data/VERSION.yml +5 -0
  5. data/bin/screw_unit +6 -0
  6. data/bin/screw_unit_server +14 -0
  7. data/core/CHANGES +10 -0
  8. data/core/EXAMPLE.html +68 -0
  9. data/core/LICENSE +22 -0
  10. data/core/README.markdown +307 -0
  11. data/core/example/models/cat.js +5 -0
  12. data/core/example/models/man.js +17 -0
  13. data/core/example/spec/matchers/have.js +8 -0
  14. data/core/example/spec/models/cat_spec.js +31 -0
  15. data/core/example/spec/models/man_spec.js +34 -0
  16. data/core/example/spec/spec_helper.js +5 -0
  17. data/core/example/spec/suite.html +25 -0
  18. data/core/lib/jquery-1.3.2.js +4376 -0
  19. data/core/lib/jquery.fn.js +30 -0
  20. data/core/lib/jquery.print.js +109 -0
  21. data/core/lib/screw.behaviors.js +93 -0
  22. data/core/lib/screw.builder.js +95 -0
  23. data/core/lib/screw.css +90 -0
  24. data/core/lib/screw.events.js +45 -0
  25. data/core/lib/screw.matchers.js +244 -0
  26. data/core/spec/behaviors_spec.js +166 -0
  27. data/core/spec/matchers_spec.js +372 -0
  28. data/core/spec/print_spec.js +158 -0
  29. data/core/spec/spec_helper.js +0 -0
  30. data/core/spec/suite.html +19 -0
  31. data/core/spec/with_screw_context_spec.js +9 -0
  32. data/init.rb +0 -0
  33. data/lib/screw_unit.rb +21 -0
  34. data/spec/functional/functional_spec.rb +25 -0
  35. data/spec/functional/functional_spec_helper.rb +42 -0
  36. data/spec/functional/functional_spec_server_starter.rb +68 -0
  37. data/spec/functional_suite.rb +10 -0
  38. data/spec/spec_suite.rb +2 -0
  39. data/standalone.ru +3 -0
  40. data/vendor/js-test-core/CHANGES +31 -0
  41. data/vendor/js-test-core/README +6 -0
  42. data/vendor/js-test-core/Rakefile +73 -0
  43. data/vendor/js-test-core/bin/js-test-client +0 -0
  44. data/vendor/js-test-core/bin/js-test-server +6 -0
  45. data/vendor/js-test-core/lib/js_test_core.rb +38 -0
  46. data/vendor/js-test-core/lib/js_test_core/app.rb +11 -0
  47. data/vendor/js-test-core/lib/js_test_core/client.rb +139 -0
  48. data/vendor/js-test-core/lib/js_test_core/configuration.rb +65 -0
  49. data/vendor/js-test-core/lib/js_test_core/representations.rb +13 -0
  50. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +25 -0
  51. data/vendor/js-test-core/lib/js_test_core/representations/frameworks.rb +3 -0
  52. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +16 -0
  53. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  54. data/vendor/js-test-core/lib/js_test_core/representations/suite.html.rb +57 -0
  55. data/vendor/js-test-core/lib/js_test_core/representations/suites.rb +3 -0
  56. data/vendor/js-test-core/lib/js_test_core/representations/suites/screw_unit.html.rb +81 -0
  57. data/vendor/js-test-core/lib/js_test_core/resources.rb +15 -0
  58. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  59. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +62 -0
  60. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  61. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +28 -0
  62. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  63. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +51 -0
  64. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +15 -0
  65. data/vendor/js-test-core/lib/js_test_core/server.rb +84 -0
  66. data/vendor/js-test-core/public/js_test_server.js +541 -0
  67. data/vendor/js-test-core/spec/example_framework/JsTestCore.css +0 -0
  68. data/vendor/js-test-core/spec/example_framework/JsTestCore.js +0 -0
  69. data/vendor/js-test-core/spec/example_framework/subdir/SubDirFile.js +0 -0
  70. data/vendor/js-test-core/spec/example_root/favicon.ico +0 -0
  71. data/vendor/js-test-core/spec/example_root/javascripts/foo.js +3 -0
  72. data/vendor/js-test-core/spec/example_root/javascripts/large_file.js +59 -0
  73. data/vendor/js-test-core/spec/example_root/javascripts/subdir/bar.js +1 -0
  74. data/vendor/js-test-core/spec/example_root/robots.txt +0 -0
  75. data/vendor/js-test-core/spec/example_root/stylesheets/example.css +3 -0
  76. data/vendor/js-test-core/spec/example_spec/custom_dir_and_suite/passing_spec.js +8 -0
  77. data/vendor/js-test-core/spec/example_spec/custom_suite.html +8 -0
  78. data/vendor/js-test-core/spec/example_spec/failing_spec.js +7 -0
  79. data/vendor/js-test-core/spec/example_spec/foo/failing_spec.js +8 -0
  80. data/vendor/js-test-core/spec/example_spec/foo/passing_spec.js +8 -0
  81. data/vendor/js-test-core/spec/example_spec/passing_spec.js +8 -0
  82. data/vendor/js-test-core/spec/functional/functional_spec.rb +25 -0
  83. data/vendor/js-test-core/spec/functional/functional_spec_helper.rb +42 -0
  84. data/vendor/js-test-core/spec/functional/functional_spec_server_starter.rb +77 -0
  85. data/vendor/js-test-core/spec/functional_suite.rb +10 -0
  86. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  87. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  88. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +16 -0
  89. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  90. data/vendor/js-test-core/spec/spec_suite.rb +3 -0
  91. data/vendor/js-test-core/spec/specs/failing_spec.js +0 -0
  92. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +196 -0
  93. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +50 -0
  94. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  95. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +81 -0
  96. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  97. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  98. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +149 -0
  99. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +28 -0
  100. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +66 -0
  101. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +30 -0
  102. data/vendor/js-test-core/spec/unit_suite.rb +10 -0
  103. data/vendor/js-test-core/standalone.ru +1 -0
  104. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +77 -0
  105. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +5 -0
  106. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +142 -0
  107. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource/path.rb +24 -0
  108. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  109. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  110. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +276 -0
  111. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  112. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
  113. data/vendor/js-test-core/vendor/lucky-luciano/syntax_ideas.txt +34 -0
  114. metadata +201 -0
@@ -0,0 +1,50 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ describe Configuration do
5
+ attr_reader :result
6
+
7
+ before do
8
+ @result = ""
9
+ end
10
+
11
+ describe "#spec_root" do
12
+ it "returns the Dir " do
13
+ Configuration.spec_path.should == spec_path
14
+ end
15
+ end
16
+
17
+ describe "#spec_path" do
18
+ it "returns the absolute path of the specs root directory" do
19
+ Configuration.spec_path.should == spec_path
20
+ end
21
+ end
22
+
23
+ describe "#root_path" do
24
+ it "returns the expanded path of the public path" do
25
+ Configuration.root_path.should == root_path
26
+ end
27
+ end
28
+
29
+ describe "#framework_path" do
30
+ it "returns the expanded path to the JsTestCore core directory" do
31
+ Configuration.framework_path.should == framework_path
32
+ end
33
+ end
34
+
35
+ describe "#js_test_core_js_path" do
36
+ it "returns the path to js_test_core.js" do
37
+ ::File.read(Configuration.js_test_core_js_path).should include("function JsTestServer()")
38
+ end
39
+ end
40
+
41
+ describe "#root_url" do
42
+ it "returns the url of the site's root" do
43
+ configuration = Configuration.new
44
+ configuration.host = "localhost"
45
+ configuration.port = 9999
46
+ configuration.root_url.should == "http://localhost:9999"
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe CoreFile do
6
+ describe "Files" do
7
+ describe "GET /core/JsTestCore.js" do
8
+ it "renders the JsTestCore.js file, which lives in the core framework directory" do
9
+ absolute_path = "#{framework_path}/JsTestCore.js"
10
+
11
+ response = get(CoreFile.path("JsTestCore.js"))
12
+ response.should be_http(
13
+ 200,
14
+ {
15
+ "Content-Type" => "text/javascript",
16
+ "Last-Modified" => ::File.mtime(absolute_path).rfc822
17
+ },
18
+ ::File.read(absolute_path)
19
+ )
20
+ end
21
+ end
22
+ end
23
+
24
+ describe "Directories" do
25
+ macro "returns a page with the files in the root core directory" do |relative_path|
26
+ it "returns a page with the files in the root core directory" do
27
+ response = get(CoreFile.path(relative_path))
28
+ response.should be_http(
29
+ 200,
30
+ {},
31
+ ""
32
+ )
33
+ doc = Nokogiri::HTML(response.body)
34
+ links = doc.search("a").map {|script| script["href"]}
35
+ links.should include("/core/JsTestCore.js")
36
+ links.should include("/core/JsTestCore.css")
37
+ links.should include("/core/subdir")
38
+ end
39
+ end
40
+ describe "GET /core" do
41
+ send("returns a page with the files in the root core directory", "")
42
+ end
43
+ describe "GET /core/" do
44
+ send("returns a page with the files in the root core directory", "/")
45
+ end
46
+
47
+ describe "GET /core/subdir" do
48
+ it "returns a page with the files in the directory" do
49
+ response = get(CoreFile.path("subdir"))
50
+ response.should be_http(
51
+ 200,
52
+ {},
53
+ %r(<a href="/core/subdir/SubDirFile.js">SubDirFile.js</a>)
54
+ )
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,81 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe File do
6
+ describe "Files" do
7
+ describe "GET /stylesheets/example.css" do
8
+ it "returns the example.css file content as a css file" do
9
+ path = "#{root_path}/stylesheets/example.css"
10
+ response = get("/stylesheets/example.css")
11
+ response.should be_http(
12
+ 200,
13
+ {
14
+ 'Content-Length' => ::File.size(path).to_s,
15
+ 'Content-Type' => "text/css",
16
+ 'Last-Modified' => ::File.mtime(path).rfc822
17
+ },
18
+ ::File.read(path)
19
+ )
20
+ end
21
+ end
22
+
23
+ describe "GET /javascripts/foo.js" do
24
+ it "returns the foo.js file content as a javascript file" do
25
+ path = "#{root_path}/javascripts/foo.js"
26
+ response = get("/javascripts/foo.js")
27
+ response.should be_http(
28
+ 200,
29
+ {
30
+ 'Content-Length' => ::File.size(path).to_s,
31
+ 'Content-Type' => "text/javascript",
32
+ 'Last-Modified' => ::File.mtime(path).rfc822
33
+ },
34
+ ::File.read(path)
35
+ )
36
+ end
37
+ end
38
+
39
+ describe "GET /javascripts/subdir/bar.js - Subdirectory" do
40
+ it "returns the subdir/bar.js file content as a javascript file" do
41
+ path = "#{root_path}/javascripts/subdir/bar.js"
42
+ response = get("/javascripts/subdir/bar.js")
43
+ response.should be_http(
44
+ 200,
45
+ {
46
+ 'Content-Length' => ::File.size(path).to_s,
47
+ 'Content-Type' => "text/javascript",
48
+ 'Last-Modified' => ::File.mtime(path).rfc822
49
+ },
50
+ ::File.read(path)
51
+ )
52
+ end
53
+ end
54
+ end
55
+
56
+ describe "Directories" do
57
+ describe "GET /stylesheets - Top level directory" do
58
+ it "returns a page with a of files in the directory" do
59
+ response = get("/stylesheets")
60
+ response.should be_http(
61
+ 200,
62
+ {},
63
+ %r(<a href="/stylesheets/example.css">example.css</a>)
64
+ )
65
+ end
66
+ end
67
+
68
+ describe "GET /javascripts/subdir - Subdirectory" do
69
+ it "returns a page with a of files in the directory" do
70
+ response = get("/javascripts/subdir")
71
+ response.should be_http(
72
+ 200,
73
+ {},
74
+ %r(<a href="/javascripts/subdir/bar.js">bar.js</a>)
75
+ )
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe ImplementationsDeprecation do
6
+ describe "GET /implementations/*" do
7
+ it "responds with a 301 to /javascripts/*" do
8
+ response = get(ImplementationsDeprecation.path("/subdir/bar.js"))
9
+ response.should be_http(
10
+ 301,
11
+ {'Location' => File.path("/javascripts/subdir/bar.js")},
12
+ "This page has been moved to #{File.path("/javascripts/subdir/bar.js")}"
13
+ )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,51 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe WebRoot do
6
+ describe "GET / - ResourceNotFound" do
7
+ it "returns a 404 error" do
8
+ response = get("/i_dont_exist")
9
+ response.should be_http(
10
+ 404,
11
+ {},
12
+ Regexp.new("File /i_dont_exist not found")
13
+ )
14
+ end
15
+ end
16
+
17
+ describe "PUT / - ResourceNotFound" do
18
+ it "returns a 404 error" do
19
+ response = put("/i_dont_exist")
20
+ response.should be_http(
21
+ 404,
22
+ {},
23
+ Regexp.new("File /i_dont_exist not found")
24
+ )
25
+ end
26
+ end
27
+
28
+ describe "POST / - ResourceNotFound" do
29
+ it "returns a 404 error" do
30
+ response = post("/i_dont_exist")
31
+ response.should be_http(
32
+ 404,
33
+ {},
34
+ Regexp.new("File /i_dont_exist not found")
35
+ )
36
+ end
37
+ end
38
+
39
+ describe "DELETE / - ResourceNotFound" do
40
+ it "returns a 404 error" do
41
+ response = delete("/i_dont_exist")
42
+ response.should be_http(
43
+ 404,
44
+ {},
45
+ Regexp.new("File /i_dont_exist not found")
46
+ )
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,149 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe SpecFile do
6
+ describe "Configuration" do
7
+ attr_reader :doc
8
+ before do
9
+ JsTestCore.framework_name = "screw-unit"
10
+ JsTestCore::Representations::Suite.project_js_files += ["/javascripts/test_file_1.js", "/javascripts/test_file_2.js"]
11
+ JsTestCore::Representations::Suite.project_css_files += ["/stylesheets/test_file_1.css", "/stylesheets/test_file_2.css"]
12
+
13
+ response = get(SpecFile.path("/failing_spec"))
14
+ response.should be_http( 200, {}, "" )
15
+
16
+ @doc = Nokogiri::HTML(response.body)
17
+ end
18
+
19
+ after do
20
+ JsTestCore::Representations::Suite.project_js_files.clear
21
+ JsTestCore::Representations::Suite.project_css_files.clear
22
+ end
23
+
24
+ it "renders project js files" do
25
+ doc.at("script[@src='/javascripts/test_file_1.js']").should_not be_nil
26
+ doc.at("script[@src='/javascripts/test_file_2.js']").should_not be_nil
27
+ end
28
+
29
+ it "renders project css files" do
30
+ doc.at("link[@href='/stylesheets/test_file_1.css']").should_not be_nil
31
+ doc.at("link[@href='/stylesheets/test_file_2.css']").should_not be_nil
32
+ end
33
+ end
34
+
35
+ describe "Files" do
36
+ describe "GET /specs/failing_spec" do
37
+ it "renders a suite only for failing_spec.js as text/html" do
38
+ absolute_path = "#{spec_path}/failing_spec.js"
39
+
40
+ response = get(SpecFile.path("failing_spec"))
41
+ response.should be_http(
42
+ 200,
43
+ {
44
+ "Content-Type" => "text/html",
45
+ "Last-Modified" => ::File.mtime(absolute_path).rfc822
46
+ },
47
+ ""
48
+ )
49
+ doc = Nokogiri::HTML(response.body)
50
+ js_files = doc.search("script").map {|script| script["src"]}
51
+ js_files.should include("/specs/failing_spec.js")
52
+ end
53
+ end
54
+
55
+ describe "GET /specs/failing_spec.js" do
56
+ it "renders the contents of failing_spec.js as text/javascript" do
57
+ absolute_path = "#{spec_path}/failing_spec.js"
58
+
59
+ response = get(SpecFile.path("failing_spec.js"))
60
+ response.should be_http(
61
+ 200,
62
+ {
63
+ "Content-Type" => "text/javascript",
64
+ "Last-Modified" => ::File.mtime(absolute_path).rfc822
65
+ },
66
+ ::File.read(absolute_path)
67
+ )
68
+ end
69
+ end
70
+
71
+ describe "GET /specs/custom_suite" do
72
+ it "renders the custom_suite.html file" do
73
+ path = "#{spec_path}/custom_suite.html"
74
+
75
+ response = get(SpecFile.path("custom_suite.html"))
76
+ response.should be_http(
77
+ 200,
78
+ {
79
+ "Content-Type" => "text/html",
80
+ "Last-Modified" => ::File.mtime(path).rfc822
81
+ },
82
+ ::File.read(path)
83
+ )
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "Directories" do
89
+ describe "GET /specs" do
90
+ macro "renders a suite for all specs" do |relative_path|
91
+ it "renders a suite for all specs" do
92
+ path = "#{spec_path}"
93
+
94
+ response = get(relative_path)
95
+ response.should be_http(
96
+ 200,
97
+ {
98
+ "Content-Type" => "text/html",
99
+ "Last-Modified" => ::File.mtime(path).rfc822
100
+ },
101
+ ""
102
+ )
103
+ doc = Nokogiri::HTML(response.body)
104
+ js_files = doc.search("script").map {|script| script["src"]}
105
+ js_files.should include("/specs/failing_spec.js")
106
+ js_files.should include("/specs/custom_dir_and_suite/passing_spec.js")
107
+ js_files.should include("/specs/foo/passing_spec.js")
108
+ js_files.should include("/specs/foo/failing_spec.js")
109
+ end
110
+ end
111
+
112
+ send("renders a suite for all specs", SpecFile.path)
113
+ send("renders a suite for all specs", SpecFile.path("/"))
114
+ end
115
+
116
+ describe "GET /specs/foo" do
117
+ it "renders a spec suite that includes all of the javascript spec files in the directory" do
118
+ path = "#{spec_path}/foo"
119
+
120
+ response = get(SpecFile.path("foo"))
121
+ response.should be_http(
122
+ 200,
123
+ {
124
+ "Content-Type" => "text/html",
125
+ "Last-Modified" => ::File.mtime(path).rfc822
126
+ },
127
+ ""
128
+ )
129
+ doc = Nokogiri::HTML(response.body)
130
+ js_files = doc.search("script").map {|script| script["src"]}
131
+ js_files.should include("/specs/foo/passing_spec.js")
132
+ js_files.should include("/specs/foo/failing_spec.js")
133
+ end
134
+ end
135
+ end
136
+
137
+ describe "GET /specs/i_dont_exist" do
138
+ it "renders a 404" do
139
+ response = get(SpecFile.path("i_dont_exist"))
140
+ response.should be_http(
141
+ 404,
142
+ {},
143
+ "/specs/i_dont_exist not found"
144
+ )
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ module Resources
5
+ describe WebRoot do
6
+ macro("includes a link to the spec suite") do |relative_path|
7
+ it "includes a link to the spec suite" do
8
+ response = get(relative_path)
9
+ response.should be_http(
10
+ 200,
11
+ {},
12
+ ""
13
+ )
14
+ doc = Nokogiri::HTML(response.body)
15
+ doc.css("a[href='/specs']").should_not be_nil
16
+ end
17
+ end
18
+
19
+ describe "GET " do
20
+ send("includes a link to the spec suite", "")
21
+ end
22
+
23
+ describe "GET /" do
24
+ send("includes a link to the spec suite", "/")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,66 @@
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../unit_spec_helper")
2
+
3
+ module JsTestCore
4
+ describe Server do
5
+ describe ".cli" do
6
+ attr_reader :server, :builder, :stdout, :rackup_path
7
+ before do
8
+ @server = Server.new
9
+ @builder = "builder"
10
+
11
+ @stdout = StringIO.new
12
+ Server.const_set(:STDOUT, stdout)
13
+
14
+ @rackup_path = File.expand_path("#{File.dirname(__FILE__)}/../../../standalone.ru")
15
+ end
16
+
17
+ after do
18
+ Server.__send__(:remove_const, :STDOUT)
19
+ end
20
+
21
+
22
+ context "when the --framework-name and --framework-path are set" do
23
+ it "starts the server and sets SpecFile::suite_representation_class to be the ScrewUnit suite" do
24
+ project_spec_dir = File.expand_path("#{File.dirname(__FILE__)}/../..")
25
+
26
+ mock.proxy(Thin::Runner).new(["--port", "8081", "--rackup", rackup_path, "start"]) do |runner|
27
+ mock(runner).run!
28
+ end
29
+
30
+ stub.proxy(Rack::Builder).new do |builder|
31
+ mock.proxy(builder).use(JsTestCore::App)
32
+ stub.proxy(builder).use
33
+ mock(builder).run(is_a(JsTestCore::App))
34
+ mock(builder).run(is_a(Sinatra::Application))
35
+ end
36
+
37
+ server.cli(
38
+ "--framework-name", "screw-unit",
39
+ "--framework-path", "#{project_spec_dir}/example_framework",
40
+ "--root-path", "#{project_spec_dir}/example_root",
41
+ "--spec-path", "#{project_spec_dir}/example_spec",
42
+ "--port", "8081"
43
+ )
44
+
45
+ JsTestCore::Configuration.instance.suite_representation_class.should == JsTestCore::Representations::Suites::ScrewUnit
46
+ end
47
+ end
48
+
49
+ context "when the --framework-name or --framework-path are not set" do
50
+ it "raises an ArgumentError" do
51
+ lambda do
52
+ server.cli
53
+ end.should raise_error(ArgumentError)
54
+
55
+ lambda do
56
+ server.cli("--framework-name", "screw-unit")
57
+ end.should raise_error(ArgumentError)
58
+
59
+ lambda do
60
+ server.cli("--framework-path", "/path/to/framework")
61
+ end.should raise_error(ArgumentError)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end