0
0
Fork 0

Kill all mutants in Zero::Renderer

This commit is contained in:
Stormwind 2013-01-06 17:39:57 +01:00
parent e81dff9c07
commit 2c558846ec
5 changed files with 26 additions and 3 deletions

View File

@ -125,7 +125,8 @@ module Zero
types.each do |type|
template = templates[name][type]
unless template.nil?
return template if template.kind_of?(Tilt::Template)
# TODO Will be implemented later
# return template if template.kind_of?(Tilt::Template)
return Tilt.new(template)
end
end

View File

@ -0,0 +1 @@
<%= name %>

View File

@ -6,7 +6,13 @@ describe Zero::Renderer, 'read_template_path!' do
let(:file_list) { ['foo/welcome/index.html.erb'] }
before :each do
subject.stub(:search_files).and_return(file_list)
Dir.stub(:[]) do |arg|
if arg == 'foo/**/*.*'
file_list
else
[]
end
end
end
shared_examples_for 'a template loader' do
@ -50,4 +56,11 @@ describe Zero::Renderer, 'read_template_path!' do
it_behaves_like 'a template loader'
end
it 'creates an empty templates list without templates in path' do
subject = Zero::Renderer.new("bar", {})
subject.read_template_path!
subject.templates.should eq({})
end
end

View File

@ -3,7 +3,6 @@ require 'spec_helper'
describe Zero::Renderer, '#render' do
subject { Zero::Renderer.new(template_path, type_map) }
let(:template_path) { 'spec/fixtures/templates' }
let(:file_list) { ['./foo/welcome/index.html.erb'] }
let(:type_map) {{
'html' => ['text/html', 'text/xml', '*/*'],
'json' => ['application/json', 'plain/text']
@ -47,4 +46,9 @@ describe Zero::Renderer, '#render' do
"No template found for any of this types #{foo_types.join ', '}!"
)
end
it 'uses the context' do
subject.render('context', html_types, binding).should match('foo')
end
end

View File

@ -6,4 +6,8 @@ describe Zero::Renderer, '#type_map' do
let(:type_map) { {'html' => ['text/html']} }
its(:type_map) { should be(type_map) }
it 'returns an empty Hash, if type_map is not set while initialization' do
Zero::Renderer.new(template_path).type_map.should eq({})
end
end