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 45
|
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 }"
assert_equal "text/css", last_response.headers['content-type']
get '/test.foo'
assert_body "Hello"
assert_equal "text/html", last_response.headers['content-type']
get '/test'
assert_body "No extension"
assert_equal "text/html", last_response.headers['content-type']
end
end
__END__
@@ /style.css
* { margin: 0; padding: 0 }
@@ /test.foo
Hello
@@ /test
No extension
|