2017-07-24 16:20:53 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:54:50 -04:00
|
|
|
require "abstract_unit"
|
2009-05-13 20:00:36 -04:00
|
|
|
|
|
|
|
module RenderFile
|
|
|
|
class BasicController < ActionController::Base
|
2017-05-15 10:17:28 -04:00
|
|
|
self.view_paths = __dir__
|
2009-10-03 23:02:51 -04:00
|
|
|
|
2009-05-13 20:00:36 -04:00
|
|
|
def index
|
2020-05-05 15:58:55 -04:00
|
|
|
render file: File.expand_path("../../fixtures/test/hello_world.erb", __dir__)
|
2009-05-13 20:00:36 -04:00
|
|
|
end
|
2009-10-03 23:02:51 -04:00
|
|
|
|
2009-05-13 20:00:36 -04:00
|
|
|
def pathname
|
2020-05-05 15:58:55 -04:00
|
|
|
render file: Pathname.new(__dir__).join(*%w[.. .. fixtures test dot.directory render_file_with_ivar.erb])
|
2009-05-13 20:00:36 -04:00
|
|
|
end
|
|
|
|
end
|
2009-10-03 23:02:51 -04:00
|
|
|
|
2009-10-04 00:18:32 -04:00
|
|
|
class TestBasic < Rack::TestCase
|
2009-05-13 20:00:36 -04:00
|
|
|
testing RenderFile::BasicController
|
2009-10-03 23:02:51 -04:00
|
|
|
|
2020-05-05 15:58:55 -04:00
|
|
|
test "rendering simple file" do
|
|
|
|
get :index
|
2009-05-13 20:00:36 -04:00
|
|
|
assert_response "Hello world!"
|
|
|
|
end
|
2009-10-03 23:02:51 -04:00
|
|
|
|
2009-05-13 20:00:36 -04:00
|
|
|
test "rendering a Pathname" do
|
2020-05-05 15:58:55 -04:00
|
|
|
get :pathname
|
|
|
|
assert_response "The secret is <%= @secret %>\n"
|
2009-05-13 20:00:36 -04:00
|
|
|
end
|
|
|
|
end
|
2009-09-13 17:30:27 -04:00
|
|
|
end
|