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.
Files changed (141) hide show
  1. data/CHANGES +44 -1
  2. data/README.markdown +17 -5
  3. data/Rakefile +28 -55
  4. data/VERSION.yml +5 -0
  5. data/bin/screw_unit_server +8 -4
  6. data/core/CHANGES +10 -0
  7. data/core/EXAMPLE.html +4 -4
  8. data/core/README.markdown +7 -7
  9. data/core/example/models/man.js +2 -2
  10. data/core/example/spec/suite.html +1 -1
  11. data/core/lib/jquery-1.3.2.js +4376 -0
  12. data/core/lib/jquery.fn.js +2 -1
  13. data/core/lib/jquery.print.js +13 -12
  14. data/core/lib/screw.behaviors.js +11 -9
  15. data/core/lib/screw.builder.js +26 -11
  16. data/core/lib/screw.css +2 -2
  17. data/core/lib/screw.events.js +11 -4
  18. data/core/lib/screw.matchers.js +192 -13
  19. data/core/spec/behaviors_spec.js +11 -1
  20. data/core/spec/matchers_spec.js +288 -9
  21. data/core/spec/print_spec.js +47 -8
  22. data/core/spec/suite.html +2 -1
  23. data/core/spec/with_screw_context_spec.js +9 -0
  24. data/lib/screw_unit.rb +12 -17
  25. data/spec/functional/functional_spec.rb +15 -4
  26. data/spec/functional/functional_spec_helper.rb +22 -35
  27. data/spec/functional/functional_spec_server_starter.rb +68 -0
  28. data/spec/spec_suite.rb +0 -1
  29. data/standalone.ru +3 -0
  30. data/vendor/js-test-core/CHANGES +22 -0
  31. data/vendor/js-test-core/README +4 -10
  32. data/vendor/js-test-core/Rakefile +2 -1
  33. data/vendor/js-test-core/{spec/example_core/JsTestCore.css → bin/js-test-client} +0 -0
  34. data/vendor/js-test-core/bin/js-test-server +6 -0
  35. data/vendor/js-test-core/lib/js_test_core.rb +27 -19
  36. data/vendor/js-test-core/lib/js_test_core/app.rb +11 -0
  37. data/vendor/js-test-core/lib/js_test_core/client.rb +125 -36
  38. data/vendor/js-test-core/lib/js_test_core/configuration.rb +65 -0
  39. data/vendor/js-test-core/lib/js_test_core/representations.rb +13 -0
  40. data/vendor/js-test-core/lib/js_test_core/representations/dir.html.rb +25 -0
  41. data/vendor/js-test-core/lib/js_test_core/representations/frameworks.rb +3 -0
  42. data/vendor/js-test-core/lib/js_test_core/representations/not_found.html.rb +16 -0
  43. data/vendor/js-test-core/lib/js_test_core/representations/page.html.rb +41 -0
  44. data/vendor/js-test-core/lib/js_test_core/representations/suite.html.rb +57 -0
  45. data/vendor/js-test-core/lib/js_test_core/representations/suites.rb +3 -0
  46. data/vendor/js-test-core/lib/js_test_core/representations/suites/screw_unit.html.rb +81 -0
  47. data/vendor/js-test-core/lib/js_test_core/resources.rb +12 -8
  48. data/vendor/js-test-core/lib/js_test_core/resources/core_file.rb +19 -0
  49. data/vendor/js-test-core/lib/js_test_core/resources/file.rb +43 -13
  50. data/vendor/js-test-core/lib/js_test_core/resources/implementations_deprecation.rb +12 -0
  51. data/vendor/js-test-core/lib/js_test_core/resources/not_found.rb +28 -0
  52. data/vendor/js-test-core/lib/js_test_core/resources/resource.rb +16 -0
  53. data/vendor/js-test-core/lib/js_test_core/resources/spec_file.rb +51 -0
  54. data/vendor/js-test-core/lib/js_test_core/resources/web_root.rb +7 -54
  55. data/vendor/js-test-core/lib/js_test_core/server.rb +65 -92
  56. data/vendor/js-test-core/public/js_test_server.js +541 -0
  57. data/vendor/js-test-core/spec/{example_core/JsTestCore.js → example_framework/JsTestCore.css} +0 -0
  58. data/vendor/js-test-core/spec/{example_public/favicon.ico → example_framework/JsTestCore.js} +0 -0
  59. data/vendor/js-test-core/spec/{example_public/robots.txt → example_framework/subdir/SubDirFile.js} +0 -0
  60. data/vendor/js-test-core/spec/example_root/favicon.ico +0 -0
  61. data/vendor/js-test-core/spec/{example_public → example_root}/javascripts/foo.js +1 -1
  62. data/vendor/js-test-core/spec/example_root/javascripts/large_file.js +59 -0
  63. data/vendor/js-test-core/spec/example_root/javascripts/subdir/bar.js +1 -0
  64. data/vendor/js-test-core/spec/example_root/robots.txt +0 -0
  65. data/vendor/js-test-core/spec/{example_public → example_root}/stylesheets/example.css +0 -0
  66. data/vendor/js-test-core/spec/example_spec/custom_dir_and_suite/passing_spec.js +8 -0
  67. data/vendor/js-test-core/spec/example_spec/custom_suite.html +8 -0
  68. data/vendor/js-test-core/spec/example_spec/failing_spec.js +7 -0
  69. data/vendor/js-test-core/spec/example_spec/foo/failing_spec.js +8 -0
  70. data/vendor/js-test-core/spec/example_spec/foo/passing_spec.js +8 -0
  71. data/vendor/js-test-core/spec/example_spec/passing_spec.js +8 -0
  72. data/vendor/js-test-core/spec/functional/functional_spec.rb +25 -0
  73. data/vendor/js-test-core/spec/functional/functional_spec_helper.rb +42 -0
  74. data/vendor/js-test-core/spec/functional/functional_spec_server_starter.rb +77 -0
  75. data/vendor/js-test-core/spec/functional_suite.rb +10 -0
  76. data/vendor/js-test-core/spec/spec_helpers/be_http.rb +32 -0
  77. data/vendor/js-test-core/spec/spec_helpers/example_group.rb +36 -0
  78. data/vendor/js-test-core/spec/spec_helpers/fake_selenium_driver.rb +16 -0
  79. data/vendor/js-test-core/spec/spec_helpers/show_test_exceptions.rb +22 -0
  80. data/vendor/js-test-core/spec/spec_suite.rb +2 -1
  81. data/vendor/js-test-core/spec/unit/js_test_core/client_spec.rb +153 -94
  82. data/vendor/js-test-core/spec/unit/js_test_core/configuration_spec.rb +50 -0
  83. data/vendor/js-test-core/spec/unit/js_test_core/resources/core_file_spec.rb +60 -0
  84. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_spec.rb +61 -68
  85. data/vendor/js-test-core/spec/unit/js_test_core/resources/implementations_deprecation_spec.rb +18 -0
  86. data/vendor/js-test-core/spec/unit/js_test_core/resources/not_found_spec.rb +51 -0
  87. data/vendor/js-test-core/spec/unit/js_test_core/resources/spec_file_spec.rb +149 -0
  88. data/vendor/js-test-core/spec/unit/js_test_core/resources/web_root_spec.rb +14 -89
  89. data/vendor/js-test-core/spec/unit/js_test_core/server_spec.rb +41 -106
  90. data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +19 -114
  91. data/vendor/js-test-core/standalone.ru +1 -0
  92. data/vendor/js-test-core/vendor/lucky-luciano/README.markdown +77 -0
  93. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano.rb +5 -0
  94. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource.rb +142 -0
  95. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/resource/path.rb +24 -0
  96. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec.rb +4 -0
  97. data/vendor/js-test-core/vendor/lucky-luciano/lib/lucky_luciano/rspec/be_http.rb +32 -0
  98. data/vendor/js-test-core/vendor/lucky-luciano/spec/lucky_luciano/resource_spec.rb +276 -0
  99. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_helper.rb +48 -0
  100. data/vendor/js-test-core/vendor/lucky-luciano/spec/spec_suite.rb +4 -0
  101. data/vendor/js-test-core/vendor/lucky-luciano/syntax_ideas.txt +34 -0
  102. metadata +145 -130
  103. data/core/TODO +0 -2
  104. data/core/lib/jquery-1.2.3.js +0 -3408
  105. data/core/lib/screw.assets.js +0 -36
  106. data/core/lib/screw.server.js +0 -21
  107. data/lib/screw_unit/resources.rb +0 -2
  108. data/lib/screw_unit/resources/spec.rb +0 -37
  109. data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -43
  110. data/spec/unit/js_test_core/specs/spec_file_spec.rb +0 -43
  111. data/spec/unit/unit_spec_helper.rb +0 -120
  112. data/spec/unit_suite.rb +0 -10
  113. data/vendor/js-test-core/lib/js_test_core/rack.rb +0 -2
  114. data/vendor/js-test-core/lib/js_test_core/rack/commonlogger.rb +0 -5
  115. data/vendor/js-test-core/lib/js_test_core/rails_server.rb +0 -22
  116. data/vendor/js-test-core/lib/js_test_core/resources/dir.rb +0 -52
  117. data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -15
  118. data/vendor/js-test-core/lib/js_test_core/resources/runners.rb +0 -15
  119. data/vendor/js-test-core/lib/js_test_core/resources/runners/firefox_runner.rb +0 -75
  120. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -50
  121. data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_file.rb +0 -17
  122. data/vendor/js-test-core/lib/js_test_core/resources/suite.rb +0 -24
  123. data/vendor/js-test-core/lib/js_test_core/resources/suite_finish.rb +0 -19
  124. data/vendor/js-test-core/lib/js_test_core/selenium.rb +0 -2
  125. data/vendor/js-test-core/lib/js_test_core/selenium/selenium_driver.rb +0 -5
  126. data/vendor/js-test-core/lib/js_test_core/thin.rb +0 -3
  127. data/vendor/js-test-core/lib/js_test_core/thin/backends/js_test_core_server.rb +0 -9
  128. data/vendor/js-test-core/lib/js_test_core/thin/js_test_core_connection.rb +0 -42
  129. data/vendor/js-test-core/spec/example_specs/failing_spec.js +0 -5
  130. data/vendor/js-test-core/spec/example_specs/foo/failing_spec.js +0 -6
  131. data/vendor/js-test-core/spec/example_specs/foo/passing_spec.js +0 -6
  132. data/vendor/js-test-core/spec/unit/js_test_core/rails_server_spec.rb +0 -45
  133. data/vendor/js-test-core/spec/unit/js_test_core/resources/dir_spec.rb +0 -42
  134. data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -26
  135. data/vendor/js-test-core/spec/unit/js_test_core/resources/runner_spec.rb +0 -24
  136. data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/firefox_runner_spec.rb +0 -197
  137. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -79
  138. data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_file_spec.rb +0 -42
  139. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_finish_spec.rb +0 -94
  140. data/vendor/js-test-core/spec/unit/js_test_core/resources/suite_spec.rb +0 -44
  141. data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -92
@@ -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
@@ -3,84 +3,77 @@ require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
3
3
  module JsTestCore
4
4
  module Resources
5
5
  describe File do
6
- attr_reader :request, :file
7
-
8
- before do
9
- WebRoot.dispatch_specs
10
- stub(EventMachine).send_data
11
- stub(EventMachine).close_connection
12
- @file = Resources::File.new(absolute_path, relative_path)
13
- @request = create_request('get', relative_path)
14
- end
15
-
16
- def absolute_path
17
- "#{spec_root_path}/failing_spec.js"
18
- end
19
-
20
- def relative_path
21
- "/specs/failing_spec.js"
22
- end
23
-
24
- describe "#absolute_path" do
25
- it "returns the absolute path passed into the initializer" do
26
- file.absolute_path.should == absolute_path
27
- end
28
- end
29
-
30
- describe "#relative_path" do
31
- it "returns the relative path passed into the initializer" do
32
- file.relative_path.should == relative_path
33
- end
34
- end
35
-
36
- describe "#get" do
37
- attr_reader :response
38
- before do
39
- @response = Rack::Response.new
40
- end
41
-
42
- it "returns the contents of the file" do
43
- file.get(request, response)
44
- response.body.should == ::File.read(absolute_path)
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
45
21
  end
46
22
 
47
- describe "when File has an extension" do
48
- describe '.js' do
49
- it "sets Content-Type to text/javascript" do
50
- file.get(request,response)
51
- response.content_type.should == "text/javascript"
52
- end
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
+ )
53
36
  end
37
+ end
54
38
 
55
- describe '.css' do
56
- it "sets Content-Type to text/css" do
57
- file.get(request, response)
58
- response.content_type.should == "text/css"
59
- end
60
-
61
- def absolute_path
62
- "#{core_path}/JsTestCore.css"
63
- end
64
-
65
- def relative_path
66
- "/core/JsTestCore.css"
67
- end
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
+ )
68
52
  end
69
53
  end
70
54
  end
71
55
 
72
- describe "==" do
73
- it "returns true when passed a file with the same absolute and relative paths" do
74
- file.should == Resources::File.new(absolute_path, relative_path)
75
- end
76
-
77
- it "returns false when passed a file with a different absolute or relative path" do
78
- file.should_not == Resources::File.new(absolute_path, "bogus")
79
- file.should_not == Resources::File.new("bogus", relative_path)
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
80
66
  end
81
67
 
82
- it "when passed a Dir, returns false because File is not a Dir" do
83
- file.should_not == Resources::Dir.new(absolute_path, relative_path)
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
84
77
  end
85
78
  end
86
79
  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