0
0
Fork 0

Throws ArgumentError, if given template does not exist

This commit is contained in:
Stormwind 2012-11-29 21:25:50 +01:00
parent eccd314e23
commit 67dd2aa4d5
2 changed files with 13 additions and 5 deletions

View File

@ -121,11 +121,13 @@ module Zero
# @param types [Array] the types for the template
# @return [Tilt::Template] a prepared tilt template
def template(name, types)
types.each do |type|
template = templates[name][type]
unless template.nil?
return template if template.kind_of?(Tilt::Template)
return Tilt.new(template)
if templates.has_key? name
types.each do |type|
template = templates[name][type]
unless template.nil?
return template if template.kind_of?(Tilt::Template)
return Tilt.new(template)
end
end
end
raise ArgumentError.new "No template found for '#{name}'!"

View File

@ -31,4 +31,10 @@ describe Zero::Renderer, '#render' do
it 'renders json content' do
subject.render('index', json_types, binding).should match("{text: 'success'}")
end
it 'returns an ArgumentError, if given template does not exist' do
expect {
subject.render('foobar', html_types, binding)
}.to raise_error(ArgumentError, "No template found for 'foobar'!")
end
end