Skip to content
Newer
Older
100644 66 lines (50 sloc) 1.68 KB
879db14 @dhh First commit
dhh authored
1 require 'sprockets'
2 require 'coffee-script'
3
4 Root = File.expand_path("../..", __FILE__)
5
6 Assets = Sprockets::Environment.new do |env|
2e5d241 @spadin Correcting asset path for Sprockets.
spadin authored
7 env.append_path File.join(Root, "lib", "assets", "javascripts")
11a4cdb @Thibaut Set up JS tests
Thibaut authored
8 env.append_path File.join(Root, "node_modules", "mocha")
9 env.append_path File.join(Root, "node_modules", "chai")
04068f1 @Thibaut Clean up jQuery data on node removal
Thibaut authored
10 env.append_path File.join(Root, "node_modules", "jquery", "dist")
11a4cdb @Thibaut Set up JS tests
Thibaut authored
11 env.append_path File.join(Root, "test", "javascript")
879db14 @dhh First commit
dhh authored
12 end
13
6c6241c @javan Add a slow response for testing / visualizing the progress bar
javan authored
14 class SlowResponse
15 CHUNKS = ['<html><body>', '.'*50, '.'*20, '<a href="/index.html">Home</a></body></html>']
16
17 def call(env)
18 [200, headers, self]
19 end
20
21 def each
22 CHUNKS.each do |part|
23 sleep rand(0.3..0.8)
24 yield part
25 end
26 end
27
28 def length
29 CHUNKS.join.length
30 end
31
32 def headers
33 { "Content-Length" => length.to_s, "Content-Type" => "text/html", "Cache-Control" => "no-cache, no-store, must-revalidate" }
34 end
35 end
36
879db14 @dhh First commit
dhh authored
37 map "/js" do
38 run Assets
39 end
40
02308a9 @keram handle server errors (5xx)
keram authored
41 map "/500" do
42 # throw Internal Server Error (500)
43 end
44
9d409a6 @qoobaa fixed _nonHtml to work on pathname only (without query string), added…
qoobaa authored
45 map "/withoutextension" do
46 run Rack::File.new(File.join(Root, "test", "withoutextension"), "Content-Type" => "text/html")
47 end
48
6c6241c @javan Add a slow response for testing / visualizing the progress bar
javan authored
49 map "/slow-response" do
50 run SlowResponse.new
51 end
52
caedd40 @phallguy Fix back button broken on redirect
phallguy authored
53 map "/bounce" do
54 run Proc.new{ [200, { "X-XHR-Redirected-To" => "redirect1.html", "Content-Type" => "text/html" }, File.open( File.join( Root, "test", "redirect1.html" ) ) ] }
55 end
56
da37a23 @frohoff test cases, fix
frohoff authored
57 map "/attachment.txt" do
58 run Rack::File.new(File.join(Root, "test", "attachment.html"), "Content-Type" => "text/plain")
59 end
60
61 map "/attachment.html" do
62 run Rack::File.new(File.join(Root, "test", "attachment.html"), "Content-Type" => "text/html", "Content-Disposition" => "attachment; filename=attachment.html")
63 end
4a33b63 @arthurnn Rack directory needs to run as root on rack
arthurnn authored
64
65 run Rack::Directory.new(File.join(Root, "test"))
Something went wrong with that request. Please try again.