0
0
zero/spec/unit/zero/renderer/template_finder/get_spec.rb
Gibheer 714c540e4b reworked parts of the template finder
The template finder is now the instance to ask for templates. It was
already looking for them, so it should be able to handle questions
regarding the existence of templates too.
2013-02-27 21:15:05 +01:00

28 lines
934 B
Ruby

require 'spec_helper'
describe Zero::Renderer::TemplateFinder, '#get' do
subject { described_class.new(template_path, type_map) }
let(:template_path) { 'spec/fixtures/templates/' }
let(:type_map) {{
'html' => ['text/html', 'text/xml', '*/*'],
'json' => ['application/json', 'plain/text']
}}
let(:html_types) { ['text/html'] }
let(:json_types) { ['application/json'] }
let(:foo_types) { ['foo/bar', 'bar/foo'] }
it 'returns a Tilt template' do
expect(subject.get('index', html_types)).to be_kind_of(Tilt::Template)
end
it 'raises an Error when the template is not found' do
expect { subject.get('not_exist', html_types) }.to raise_error(
ArgumentError, /Template 'not_exist' does not exist/)
end
it 'raises an Error when no type for the template was found' do
expect { subject.get('index', foo_types) }.to raise_error(
ArgumentError, /Template 'index' not found/)
end
end