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
@@ -1,36 +0,0 @@
1
- (function() {
2
- Screw.Assets = {};
3
- Screw.Assets.use_cache_buster = false; // TODO: NS/CTI - make this configurable from the UI.
4
- var required_paths = [];
5
- var included_stylesheets = {};
6
- var cache_buster = parseInt(new Date().getTime()/(1*1000));
7
-
8
- Screw.Assets.require = function(javascript_path, onload) {
9
- if(!required_paths[javascript_path]) {
10
- var full_path = javascript_path + ".js";
11
- if (Screw.Assets.use_cache_buster) {
12
- full_path += '?' + cache_buster;
13
- }
14
- document.write("<script src='" + full_path + "' type='text/javascript'></script>");
15
- if(onload) {
16
- var scripts = document.getElementsByTagName('script');
17
- scripts[scripts.length-1].onload = onload;
18
- }
19
- required_paths[javascript_path] = true;
20
- }
21
- };
22
-
23
- Screw.Assets.stylesheet = function(stylesheet_path) {
24
- if(!included_stylesheets[stylesheet_path]) {
25
- var full_path = stylesheet_path + ".css";
26
- if(Screw.Assets.use_cache_buster) {
27
- full_path += '?' + cache_buster;
28
- }
29
- document.write("<link rel='stylesheet' type='text/css' href='" + full_path + "' />");
30
- included_stylesheets[stylesheet_path] = true;
31
- }
32
- };
33
-
34
- window.require = Screw.Assets.require;
35
- window.stylesheet = Screw.Assets.stylesheet;
36
- })();
@@ -1,21 +0,0 @@
1
- (function($) {
2
- var ajax = $.ajax;
3
- $(Screw).bind('after', function() {
4
- var error_text = $(".error").map(function(i, element) {
5
- return element.innerHTML;
6
- }).get().join("\n");
7
-
8
- var suite_id;
9
- if(top.runOptions) {
10
- suite_id = top.runOptions.getSessionId();
11
- } else {
12
- suite_id = 'user';
13
- }
14
-
15
- ajax({
16
- type: "POST",
17
- url: '/suites/' + suite_id + '/finish',
18
- data: {"text": error_text}
19
- });
20
- });
21
- })(jQuery);
@@ -1,2 +0,0 @@
1
- dir = File.dirname(__FILE__)
2
- require "#{dir}/resources/spec"
@@ -1,37 +0,0 @@
1
- module ScrewUnit
2
- module Resources
3
- module Spec
4
- def get(request, response)
5
- html = <<-HTML
6
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
7
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
8
- <head>
9
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
10
- <title>ScrewUnit results</title>
11
- <script src="/core/jquery-1.2.3.js"></script>
12
- <script src="/core/jquery.fn.js"></script>
13
- <script src="/core/jquery.print.js"></script>
14
- <script src="/core/screw.builder.js"></script>
15
- <script src="/core/screw.matchers.js"></script>
16
- <script src="/core/screw.events.js"></script>
17
- <script src="/core/screw.behaviors.js"></script>
18
- <script src="/core/screw.assets.js"></script>
19
- <script src="/core/screw.server.js"></script>
20
- <link rel="stylesheet" href="/core/screw.css">
21
- HTML
22
- spec_files.each do |file|
23
- html << %{<script type="text/javascript" src="#{file.relative_path}"></script>\n}
24
- end
25
-
26
- html << <<-HTML
27
- </head>
28
- <body>
29
- <div id="screw_unit_content"></div>
30
- </body>
31
- </html>
32
- HTML
33
- response.body = html.gsub(/^ /, "")
34
- end
35
- end
36
- end
37
- end
@@ -1,43 +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
8
-
9
- before do
10
- stub(EventMachine).send_data
11
- stub(EventMachine).close_connection
12
- @dir = SpecDir.new(spec_root_path, '/specs')
13
- end
14
-
15
- describe "#get" do
16
- attr_reader :html, :doc
17
- before do
18
- request = request('get', '/specs')
19
- response = Rack::Response.new
20
- dir.get(request, response)
21
- @html = response.body
22
- @doc = Hpricot(html)
23
- end
24
-
25
- it "returns script tags for each test javascript file" do
26
- doc.at("script[@src='/specs/failing_spec.js']").should exist
27
- doc.at("script[@src='/specs/foo/failing_spec.js']").should exist
28
- doc.at("script[@src='/specs/foo/passing_spec.js']").should exist
29
- end
30
-
31
- it "returns the screw unit template" do
32
- doc.at("link[@href='/core/screw.css']").should exist
33
- doc.at("script[@src='/core/screw.builder.js']").should exist
34
- doc.at("script[@src='/core/screw.events.js']").should exist
35
- doc.at("script[@src='/core/screw.behaviors.js']").should exist
36
- doc.at("script[@src='/core/screw.assets.js']").should exist
37
- doc.at("body/#screw_unit_content").should_not be_nil
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,43 +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
- describe "#spec_files" do
8
- attr_reader :absolute_path, :relative_path, :file
9
-
10
- before do
11
- @absolute_path = "#{spec_root_path}/failing_spec.js"
12
- @relative_path = "/specs/failing_spec.js"
13
- @file = SpecFile.new(absolute_path, relative_path)
14
- end
15
-
16
- describe "#get" do
17
- attr_reader :html, :doc
18
- before do
19
- request = request('get', '/specs')
20
- response = Rack::Response.new
21
- file.get(request, response)
22
- @html = response.body
23
- @doc = Hpricot(html)
24
- end
25
-
26
- it "returns script tags for the test javascript file" do
27
- doc.at("script[@src='/specs/failing_spec.js']").should exist
28
- end
29
-
30
- it "returns the screw unit template" do
31
- doc.at("link[@href='/core/screw.css']").should exist
32
- doc.at("script[@src='/core/screw.builder.js']").should exist
33
- doc.at("script[@src='/core/screw.events.js']").should exist
34
- doc.at("script[@src='/core/screw.behaviors.js']").should exist
35
- doc.at("script[@src='/core/screw.assets.js']").should exist
36
- doc.at("body/#screw_unit_content").should_not be_nil
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,120 +0,0 @@
1
- require "rubygems"
2
- require "spec"
3
- dir = File.dirname(__FILE__)
4
-
5
- $LOAD_PATH.unshift "#{dir}/../../lib"
6
- require "screw_unit"
7
- require "hpricot"
8
- require "guid"
9
-
10
- Spec::Runner.configure do |config|
11
- config.mock_with :rr
12
- end
13
-
14
- module Spec
15
- module Matchers
16
- class Exist
17
- def matches?(actual)
18
- @actual = actual
19
- !@actual.nil?
20
- end
21
- end
22
- end
23
- end
24
-
25
- class Spec::Example::ExampleGroup
26
- class << self
27
- def thin_logging
28
- @thin_logging = true if @thin_logging.nil?
29
- @thin_logging
30
- end
31
-
32
- attr_writer :thin_logging
33
- end
34
- end
35
-
36
- module Spec::Example::ExampleMethods
37
- attr_reader :spec_root_path, :implementation_root_path, :public_path, :server, :connection
38
- before(:all) do
39
- dir = File.dirname(__FILE__)
40
- @spec_root_path = File.expand_path("#{dir}/../example_specs")
41
- @implementation_root_path = File.expand_path("#{dir}/../example_public/javascripts")
42
- @public_path = File.expand_path("#{dir}/../example_public")
43
- end
44
-
45
- before(:each) do
46
- JsTestCore::Server.instance = JsTestCore::Server.new(spec_root_path, implementation_root_path, public_path)
47
- stub(EventMachine).run do
48
- raise "You need to mock calls to EventMachine.run or the process will hang"
49
- end
50
- stub(EventMachine).start_server do
51
- raise "You need to mock calls to EventMachine.start_server or the process will hang"
52
- end
53
- stub(EventMachine).send_data do
54
- raise "Calls to EventMachine.send_data must be mocked or stubbed"
55
- end
56
- @connection = Thin::JsTestCoreConnection.new(Guid.new)
57
- stub(EventMachine).send_data {raise "EventMachine.send_data must be handled"}
58
- stub(EventMachine).close_connection {raise "EventMachine.close_connection must be handled"}
59
- @server = JsTestCore::Server.instance
60
- Thin::Logging.silent = !self.class.thin_logging
61
- Thin::Logging.debug = self.class.thin_logging
62
- end
63
-
64
- after(:each) do
65
- Thin::Logging.silent = true
66
- Thin::Logging.debug = false
67
- end
68
-
69
- def get(url, params={})
70
- request(:get, url, params)
71
- end
72
-
73
- def post(url, params={})
74
- request(:post, url, params)
75
- end
76
-
77
- def put(url, params={})
78
- request(:put, url, params)
79
- end
80
-
81
- def delete(url, params={})
82
- request(:delete, url, params)
83
- end
84
-
85
- def env_for(method, url, params)
86
- Rack::MockRequest.env_for(url, params.merge({:method => method.to_s.upcase, 'js_test_core.connection' => connection}))
87
- end
88
-
89
- def create_request(method, url, params={})
90
- env = env_for(method, url, params)
91
- server.call(env)[2]
92
- end
93
- alias_method :request, :create_request
94
-
95
- def core_path
96
- JsTestCore::Server.core_path
97
- end
98
-
99
- def spec_file(relative_path)
100
- absolute_path = spec_root_path + relative_path
101
- JsTestCore::Resources::File.new(absolute_path, "/specs#{relative_path}")
102
- end
103
-
104
- def spec_dir(relative_path="")
105
- absolute_path = spec_root_path + relative_path
106
- JsTestCore::Resources::SpecDir.new(absolute_path, "/specs#{relative_path}")
107
- end
108
-
109
- def contain_spec_file_with_correct_paths(path_relative_to_spec_root)
110
- expected_absolute_path = spec_root_path + path_relative_to_spec_root
111
- expected_relative_path = "/specs" + path_relative_to_spec_root
112
-
113
- ::Spec::Matchers::SimpleMatcher.new(expected_relative_path) do |globbed_files|
114
- file = globbed_files.find do |file|
115
- file.absolute_path == expected_absolute_path
116
- end
117
- file && file.relative_path == expected_relative_path
118
- end
119
- end
120
- end
data/spec/unit_suite.rb DELETED
@@ -1,10 +0,0 @@
1
- class UnitSuite
2
- def run
3
- dir = File.dirname(__FILE__)
4
- Dir["#{dir}/unit/**/*_spec.rb"].each do |file|
5
- require file
6
- end
7
- end
8
- end
9
-
10
- UnitSuite.new.run
@@ -1,2 +0,0 @@
1
- dir = File.dirname(__FILE__)
2
- require "#{dir}/rack/commonlogger"
@@ -1,5 +0,0 @@
1
- Rack::CommonLogger.class_eval do
2
- def empty?
3
- @body.empty?
4
- end
5
- end
@@ -1,22 +0,0 @@
1
- module JsTestCore
2
- class RailsServer < Server
3
- class << self
4
- def run(rails_root, server_options = {})
5
- server_options[:Host] ||= DEFAULT_HOST
6
- server_options[:Port] ||= DEFAULT_PORT
7
- Server.instance = new(rails_root, server_options[:Host], server_options[:Port])
8
- Server.instance.run server_options
9
- end
10
- end
11
-
12
- def initialize(rails_root, host=DEFAULT_HOST, port=DEFAULT_PORT)
13
- super(
14
- "#{rails_root}/spec/javascripts",
15
- "#{rails_root}/public/javascripts",
16
- "#{rails_root}/public",
17
- host,
18
- port
19
- )
20
- end
21
- end
22
- end
@@ -1,52 +0,0 @@
1
- module JsTestCore
2
- module Resources
3
- class Dir < File
4
- def locate(name)
5
- if file = file(name)
6
- file
7
- elsif subdir = subdir(name)
8
- subdir
9
- else
10
- raise "No file or directory found at #{relative_path}/#{name}."
11
- end
12
- end
13
-
14
- def get(request, response)
15
-
16
- end
17
-
18
- def glob(pattern)
19
- expanded_pattern = absolute_path + pattern
20
- ::Dir.glob(expanded_pattern).map do |absolute_globbed_path|
21
- relative_globbed_path = absolute_globbed_path.gsub(absolute_path, relative_path)
22
- File.new(absolute_globbed_path, relative_globbed_path)
23
- end
24
- end
25
-
26
- protected
27
- def determine_child_paths(name)
28
- absolute_child_path = "#{absolute_path}/#{name}"
29
- relative_child_path = "#{relative_path}/#{name}"
30
- [absolute_child_path, relative_child_path]
31
- end
32
-
33
- def file(name)
34
- absolute_file_path, relative_file_path = determine_child_paths(name)
35
- if ::File.exists?(absolute_file_path) && !::File.directory?(absolute_file_path)
36
- Resources::File.new(absolute_file_path, relative_file_path)
37
- else
38
- nil
39
- end
40
- end
41
-
42
- def subdir(name)
43
- absolute_dir_path, relative_dir_path = determine_child_paths(name)
44
- if ::File.directory?(absolute_dir_path)
45
- Resources::Dir.new(absolute_dir_path, relative_dir_path)
46
- else
47
- nil
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,15 +0,0 @@
1
- module JsTestCore
2
- module Resources
3
- class FileNotFound
4
- attr_reader :name
5
- def initialize(name)
6
- @name = name
7
- end
8
-
9
- def get(request, response)
10
- response.status = 404
11
- response.body = "Path #{name} not found. You may want to try the /#{WebRoot.dispatch_strategy} directory."
12
- end
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- dir = File.dirname(__FILE__)
2
-
3
- module JsTestCore
4
- module Resources
5
- class Runners
6
- def locate(name)
7
- if name == 'firefox'
8
- FirefoxRunner.new
9
- else
10
- raise "Invalid path #{name}"
11
- end
12
- end
13
- end
14
- end
15
- end