screw-unit 0.3.3 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/Rakefile +27 -25
- data/VERSION.yml +4 -0
- data/bin/screw_unit_server +14 -4
- data/core/EXAMPLE.html +1 -1
- 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/screw.behaviors.js +8 -7
- data/core/lib/screw.builder.js +34 -19
- data/core/lib/screw.css +1 -1
- data/core/lib/screw.events.js +5 -5
- data/core/lib/screw.matchers.js +59 -2
- 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/{resources/spec.rb → representations/spec.html.rb} +55 -39
- data/spec/functional/functional_spec.rb +1 -1
- data/spec/functional/functional_spec_helper.rb +21 -33
- data/spec/functional/functional_spec_server_starter.rb +68 -0
- data/spec/unit/js_test_core/specs/spec_file_spec.rb +52 -18
- data/spec/unit/unit_spec_helper.rb +24 -91
- data/vendor/js-test-core/CHANGES +8 -0
- data/vendor/js-test-core/Rakefile +1 -0
- data/vendor/js-test-core/lib/js_test_core.rb +22 -14
- data/vendor/js-test-core/lib/js_test_core/app.rb +12 -0
- data/vendor/js-test-core/lib/js_test_core/client.rb +21 -9
- data/vendor/js-test-core/lib/js_test_core/configuration.rb +35 -0
- data/vendor/js-test-core/lib/js_test_core/extensions.rb +1 -1
- 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/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 -7
- 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 +42 -20
- 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 -60
- data/vendor/js-test-core/{vendor/thin-rest/README → spec/example_core/subdir/SubDirFile.js} +0 -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 +35 -10
- 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 +54 -63
- 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 +15 -19
- data/vendor/js-test-core/spec/unit/unit_spec_helper.rb +16 -149
- 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/{thin-rest → lucky-luciano}/spec/spec_suite.rb +1 -2
- metadata +134 -145
- data/core/lib/jquery-1.2.6.js +0 -3549
- data/lib/screw_unit/resources.rb +0 -2
- data/spec/unit/js_test_core/specs/spec_dir_spec.rb +0 -38
- 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 -67
- data/vendor/js-test-core/lib/js_test_core/resources/file_not_found.rb +0 -11
- data/vendor/js-test-core/lib/js_test_core/resources/runner.rb +0 -107
- data/vendor/js-test-core/lib/js_test_core/resources/session.rb +0 -44
- data/vendor/js-test-core/lib/js_test_core/resources/session_finish.rb +0 -17
- data/vendor/js-test-core/lib/js_test_core/resources/specs/spec_dir.rb +0 -46
- 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/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 -50
- 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 -8
- 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 -52
- data/vendor/js-test-core/spec/unit/js_test_core/resources/file_not_found_spec.rb +0 -16
- data/vendor/js-test-core/spec/unit/js_test_core/resources/runners/runner_spec.rb +0 -303
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_finish_spec.rb +0 -79
- data/vendor/js-test-core/spec/unit/js_test_core/resources/session_spec.rb +0 -82
- data/vendor/js-test-core/spec/unit/js_test_core/resources/specs/spec_dir_spec.rb +0 -105
- 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/server_spec.rb +0 -117
- data/vendor/js-test-core/spec/unit/thin/js_test_core_connection_spec.rb +0 -6
- data/vendor/js-test-core/vendor/thin-rest/CHANGES +0 -2
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest.rb +0 -9
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/connection.rb +0 -116
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions.rb +0 -3
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/extensions/object.rb +0 -21
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource.rb +0 -108
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/resource_invalid.rb +0 -4
- data/vendor/js-test-core/vendor/thin-rest/lib/thin_rest/routing_error.rb +0 -5
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/connection_spec.rb +0 -207
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest/resource_spec.rb +0 -127
- data/vendor/js-test-core/vendor/thin-rest/spec/thin_rest_spec_helper.rb +0 -124
@@ -62,7 +62,7 @@ module JsTestCore
|
|
62
62
|
context "when the Session is not found" do
|
63
63
|
it "raises a SessionNotFound error" do
|
64
64
|
mock_post_to_runner("*firefox")
|
65
|
-
mock(request).get("
|
65
|
+
mock(request).get(Resources::SeleniumSession.path(":session_id", :session_id => "my_session_id")) do
|
66
66
|
stub(session_response = Object.new).code {"404"}
|
67
67
|
session_response
|
68
68
|
end
|
@@ -78,15 +78,33 @@ module JsTestCore
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
context "when passed-in a timeout" do
|
82
|
+
it "wraps a timeout around the run" do
|
83
|
+
mock.proxy(Timeout).timeout(5)
|
84
|
+
mock_post_to_runner("*firefox")
|
85
|
+
mock_polling_returns([running_status, running_status, success_status])
|
86
|
+
Client.run(:timeout => 5)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when not passed-in a timeout" do
|
91
|
+
it "does not wrap a timeout around the run" do
|
92
|
+
dont_allow(Timeout).timeout
|
93
|
+
mock_post_to_runner("*firefox")
|
94
|
+
mock_polling_returns([running_status, running_status, success_status])
|
95
|
+
Client.run
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
81
99
|
def mock_post_to_runner(selenium_browser_start_command)
|
82
100
|
mock(start_session_response = Object.new).body {"session_id=my_session_id"}
|
83
|
-
mock(request).post(
|
101
|
+
mock(request).post(Resources::SeleniumSession.path, "selenium_browser_start_command=#{CGI.escape(selenium_browser_start_command)}&selenium_host=localhost&selenium_port=4444") do
|
84
102
|
start_session_response
|
85
103
|
end
|
86
104
|
end
|
87
105
|
|
88
106
|
def mock_polling_returns(session_statuses=[])
|
89
|
-
mock(request).get("
|
107
|
+
mock(request).get(Resources::SeleniumSession.path(":session_id", :session_id => "my_session_id")) do
|
90
108
|
stub(session_response = Object.new).body {session_statuses.shift}
|
91
109
|
stub(session_response).code {"200"}
|
92
110
|
session_response
|
@@ -94,15 +112,15 @@ module JsTestCore
|
|
94
112
|
end
|
95
113
|
|
96
114
|
def running_status
|
97
|
-
"status=#{Resources::
|
115
|
+
"status=#{Resources::SeleniumSession::RUNNING}"
|
98
116
|
end
|
99
117
|
|
100
118
|
def success_status
|
101
|
-
"status=#{Resources::
|
119
|
+
"status=#{Resources::SeleniumSession::SUCCESSFUL_COMPLETION}"
|
102
120
|
end
|
103
121
|
|
104
122
|
def failure_status(reason)
|
105
|
-
"status=#{Resources::
|
123
|
+
"status=#{Resources::SeleniumSession::FAILURE_COMPLETION}&reason=#{reason}"
|
106
124
|
end
|
107
125
|
end
|
108
126
|
|
@@ -112,7 +130,7 @@ module JsTestCore
|
|
112
130
|
stub(Client).puts
|
113
131
|
end
|
114
132
|
|
115
|
-
|
133
|
+
context "when passed-in Hash contains :selenium_browser_start_command" do
|
116
134
|
it "passes the spec_url as a post parameter" do
|
117
135
|
selenium_browser_start_command = '*iexplore'
|
118
136
|
mock(Client).run(:selenium_browser_start_command => selenium_browser_start_command)
|
@@ -120,7 +138,7 @@ module JsTestCore
|
|
120
138
|
end
|
121
139
|
end
|
122
140
|
|
123
|
-
|
141
|
+
context "when passed-in Hash contains :spec_url" do
|
124
142
|
it "passes the spec_url as a post parameter" do
|
125
143
|
spec_url = 'http://foobar.com/foo'
|
126
144
|
mock(Client).run(:spec_url => spec_url)
|
@@ -128,7 +146,7 @@ module JsTestCore
|
|
128
146
|
end
|
129
147
|
end
|
130
148
|
|
131
|
-
|
149
|
+
context "when passed-in Hash contains :selenium_host" do
|
132
150
|
it "passes the selenium_host as a post parameter" do
|
133
151
|
selenium_host = 'test-runner'
|
134
152
|
mock(Client).run(:selenium_host => selenium_host)
|
@@ -136,13 +154,20 @@ module JsTestCore
|
|
136
154
|
end
|
137
155
|
end
|
138
156
|
|
139
|
-
|
157
|
+
context "when passed-in Hash contains :selenium_port" do
|
140
158
|
it "passes the selenium_port as a post parameter" do
|
141
159
|
selenium_port = "5000"
|
142
160
|
mock(Client).run(:selenium_port => selenium_port)
|
143
161
|
client = Client.run_argv(['--selenium_port', selenium_port])
|
144
162
|
end
|
145
163
|
end
|
164
|
+
|
165
|
+
context "when passed-in Hash contains :timeout" do
|
166
|
+
it "passes the timeout as a post parameter" do
|
167
|
+
mock(Client).run(:timeout => 5)
|
168
|
+
client = Client.run_argv(['--timeout', "5"])
|
169
|
+
end
|
170
|
+
end
|
146
171
|
end
|
147
172
|
|
148
173
|
describe '#parts_from_query' do
|
@@ -0,0 +1,44 @@
|
|
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_root_path.should == spec_root_path
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".spec_root_path" do
|
18
|
+
it "returns the absolute path of the specs root directory" do
|
19
|
+
Configuration.spec_root_path.should == spec_root_path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".public_path" do
|
24
|
+
it "returns the expanded path of the public path" do
|
25
|
+
Configuration.public_path.should == public_path
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".core_path" do
|
30
|
+
it "returns the expanded path to the JsTestCore core directory" do
|
31
|
+
Configuration.core_path.should == core_path
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#root_url" do
|
36
|
+
it "returns the url of the site's root" do
|
37
|
+
server = Configuration.new
|
38
|
+
server.host = "localhost"
|
39
|
+
server.port = 9999
|
40
|
+
server.root_url.should == "http://localhost:9999"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../../unit_spec_helper")
|
2
|
+
|
3
|
+
module JsTestCore
|
4
|
+
module Models
|
5
|
+
describe SeleniumSession do
|
6
|
+
attr_reader :driver, :session_id, :selenium_session
|
7
|
+
|
8
|
+
before do
|
9
|
+
@driver = FakeSeleniumDriver.new
|
10
|
+
@selenium_session = SeleniumSession.new(:spec_url => "http://localhost:8080/specs")
|
11
|
+
stub(selenium_session).driver {driver}
|
12
|
+
driver.start
|
13
|
+
@session_id = driver.session_id
|
14
|
+
SeleniumSession.register(selenium_session)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".find" do
|
18
|
+
context "when passed an id for which there is a corresponding selenium_session" do
|
19
|
+
it "returns the selenium_session" do
|
20
|
+
SeleniumSession.find(session_id).should == selenium_session
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when passed an id for which there is no corresponding selenium_session" do
|
25
|
+
it "returns nil" do
|
26
|
+
invalid_id = "666666666666666"
|
27
|
+
SeleniumSession.find(invalid_id).should be_nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#running?" do
|
33
|
+
context "when the driver#session_started? is true" do
|
34
|
+
it "returns true" do
|
35
|
+
driver.session_started?.should be_true
|
36
|
+
selenium_session.should be_running
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when the driver#session_started? is false" do
|
41
|
+
it "returns false" do
|
42
|
+
driver.stop
|
43
|
+
driver.session_started?.should be_false
|
44
|
+
selenium_session.should_not be_running
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#finalize" do
|
50
|
+
attr_reader :selenium_session
|
51
|
+
|
52
|
+
before do
|
53
|
+
mock.proxy(driver).stop
|
54
|
+
end
|
55
|
+
|
56
|
+
it "kills the browser and stores the #run_result" do
|
57
|
+
run_result = "The session run result"
|
58
|
+
selenium_session.finish(run_result)
|
59
|
+
selenium_session.run_result.should == run_result
|
60
|
+
end
|
61
|
+
|
62
|
+
it "sets #run_result" do
|
63
|
+
selenium_session.finish("the result")
|
64
|
+
selenium_session.run_result.should == "the result"
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when passed an empty string" do
|
68
|
+
it "causes #successful? to be true" do
|
69
|
+
selenium_session.finish("")
|
70
|
+
selenium_session.should be_successful
|
71
|
+
selenium_session.should_not be_failed
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when passed a non-empty string" do
|
76
|
+
it "causes #successful? to be false" do
|
77
|
+
selenium_session.finish("A bunch of error stuff")
|
78
|
+
selenium_session.should_not be_successful
|
79
|
+
selenium_session.should be_failed
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
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 = "#{core_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,86 +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
|
-
|
7
|
-
WebRoot.dispatch_specs
|
8
|
-
stub_send_data
|
9
|
-
stub(EventMachine).close_connection
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "GET" do
|
6
|
+
describe "Files" do
|
13
7
|
describe "GET /stylesheets/example.css" do
|
14
|
-
it "returns
|
8
|
+
it "returns the example.css file content as a css file" do
|
15
9
|
path = "#{public_path}/stylesheets/example.css"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe "GET /
|
24
|
-
it "returns
|
23
|
+
describe "GET /javascripts/foo.js" do
|
24
|
+
it "returns the foo.js file content as a javascript file" do
|
25
25
|
path = "#{public_path}/javascripts/foo.js"
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
+
)
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
39
|
describe "GET /javascripts/subdir/bar.js - Subdirectory" do
|
34
|
-
it "returns
|
40
|
+
it "returns the subdir/bar.js file content as a javascript file" do
|
35
41
|
path = "#{public_path}/javascripts/subdir/bar.js"
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
path = "#{public_path}/javascripts/large_file.js"
|
47
|
-
mock(connection).send_head(200, 'Content-Type' => "text/javascript", 'Content-Length' => ::File.size(path), 'Last-Modified' => ::File.mtime(path).rfc822)
|
48
|
-
::File.open(path) do |file|
|
49
|
-
while !file.eof?
|
50
|
-
chunk_count += 1
|
51
|
-
mock(connection).send_data(file.read(1024))
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
chunk_count.should == (::File.size(path) / 1024.0).ceil.to_i
|
56
|
-
connection.receive_data("GET /javascripts/large_file.js HTTP/1.1\r\nHost: _\r\n\r\n")
|
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
|
+
)
|
57
52
|
end
|
58
53
|
end
|
59
54
|
end
|
60
55
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
:relative_path => relative_path
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "returns true when passed a file with the same absolute and relative paths" do
|
76
|
-
file.should == Resources::File.new(:absolute_path => absolute_path, :relative_path => relative_path)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "returns false when passed a file with a different absolute or relative path" do
|
80
|
-
file.should_not == Resources::File.new(:absolute_path => absolute_path, :relative_path => "bogus")
|
81
|
-
file.should_not == Resources::File.new(:absolute_path => "bogus", :relative_path => 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
|
82
66
|
end
|
83
67
|
|
84
|
-
|
85
|
-
|
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
|
86
77
|
end
|
87
78
|
end
|
88
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
|