Throws ArgumentError, if given template does not exist
This commit is contained in:
parent
eccd314e23
commit
67dd2aa4d5
|
@ -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}'!"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue