forked from camping/camping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_file.rb
45 lines (34 loc) · 772 Bytes
/
app_file.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'test_helper'
require 'camping'
Camping.goes :FileSource
module FileSource::Controllers
class Index
def get
FileSource.options[:__FILE__]
end
end
end
class FileSource::Test < TestCase
def test_source
get '/'
assert_body __FILE__
end
def test_file
get '/style.css'
assert_body "* { margin: 0; padding: 0 }\n\n"
assert_equal "text/css", last_response.headers['Content-Type']
get '/test.foo'
assert_body "Hello\n\n"
assert_equal "text/html", last_response.headers['Content-Type']
get '/test'
assert_body "No extension\n\n"
assert_equal "text/html", last_response.headers['Content-Type']
end
end
__END__
@@ /style.css
* { margin: 0; padding: 0 }
@@ /test.foo
Hello
@@ /test
No extension