0
0
Fork 0

Throws an ArgumentError, if no template fits given types

This commit is contained in:
Stormwind 2012-11-29 21:41:13 +01:00
parent 67dd2aa4d5
commit 74bbc7f186
2 changed files with 13 additions and 0 deletions

View File

@ -129,6 +129,9 @@ module Zero
return Tilt.new(template)
end
end
raise ArgumentError.new(
"No template found for any of this types #{types.join ', '}!"
)
end
raise ArgumentError.new "No template found for '#{name}'!"
end

View File

@ -10,6 +10,7 @@ describe Zero::Renderer, '#render' do
}}
let(:html_types) { ['text/html'] }
let(:json_types) { ['application/json'] }
let(:foo_types) { ['foo/bar', 'bar/foo'] }
let(:binding) { SpecTemplateContext.new('foo') }
before :each do
@ -37,4 +38,13 @@ describe Zero::Renderer, '#render' do
subject.render('foobar', html_types, binding)
}.to raise_error(ArgumentError, "No template found for 'foobar'!")
end
it 'returns an ArgumentError, if no template fits types' do
expect {
subject.render('index', foo_types, binding)
}.to raise_error(
ArgumentError,
"No template found for any of this types #{foo_types.join ', '}!"
)
end
end