mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
fix bug when reloading inline templates
This commit is contained in:
parent
7b1a65b347
commit
8a26f5bb57
2 changed files with 20 additions and 3 deletions
|
@ -131,9 +131,9 @@ module Sinatra
|
|||
end
|
||||
end
|
||||
|
||||
def iniline_templates=(file=nil)
|
||||
def inline_templates=(file=nil)
|
||||
file = (file.nil? || file == true) ?
|
||||
(caller_files.first || File.expand_path($0)) : file
|
||||
(caller_files[1] || File.expand_path($0)) : file
|
||||
Watcher::List.for(self).watch_inline_templates(file)
|
||||
super
|
||||
end
|
||||
|
|
|
@ -87,13 +87,30 @@ describe Sinatra::Reloader do
|
|||
get('/foo').status.should == 404
|
||||
end
|
||||
|
||||
it "reloads inline templates" do
|
||||
it "reloads inline templates in the app file" do
|
||||
update_app_file(
|
||||
:routes => ['get("/foo") { erb :foo }'],
|
||||
:inline_templates => { :foo => 'bar' }
|
||||
)
|
||||
get('/foo').body.should == 'bar'
|
||||
end
|
||||
|
||||
it "reloads inline templates in other file" do
|
||||
setup_example_app(:routes => ['get("/foo") { erb :foo }'])
|
||||
template_file_path = File.join(tmp_dir, 'templates.rb')
|
||||
File.open(template_file_path, 'w') do |f|
|
||||
f.write "__END__\n\n@@foo\nfoo"
|
||||
end
|
||||
require template_file_path
|
||||
app_const.inline_templates= template_file_path
|
||||
get('/foo').body.should == 'foo'
|
||||
update_file(template_file_path) do |path|
|
||||
File.open(path, 'w') do |f|
|
||||
f.write "__END__\n\n@@foo\nbar"
|
||||
end
|
||||
end
|
||||
get('/foo').body.should == 'bar'
|
||||
end
|
||||
end
|
||||
|
||||
describe ".dont_reload" do
|
||||
|
|
Loading…
Reference in a new issue