0
0
zero/spec/unit/renderer/render_spec.rb

35 lines
1.0 KiB
Ruby
Raw Normal View History

2012-11-26 20:07:37 +01:00
require 'spec_helper'
describe Zero::Renderer, '#render' do
2012-11-27 21:02:07 +01:00
subject { Zero::Renderer.new(template_path, type_map) }
let(:template_path) { 'spec/fixtures/templates' }
2012-11-26 20:07:37 +01:00
let(:file_list) { ['./foo/welcome/index.html.erb'] }
2012-11-27 21:02:07 +01:00
let(:type_map) {{
'html' => ['text/html', 'text/xml', '*/*'],
'json' => ['application/json', 'plain/text']
}}
let(:html_types) { ['text/html'] }
let(:json_types) { ['application/json'] }
let(:binding) { SpecTemplateContext.new('foo') }
2012-11-26 20:07:37 +01:00
2012-11-27 21:02:07 +01:00
before :each do
subject.read_template_path!
2012-11-26 20:07:37 +01:00
end
2012-11-27 21:02:07 +01:00
it 'returns a tilt template' do
subject.render('index', html_types, binding).should be_kind_of(String)
end
2012-11-26 20:07:37 +01:00
2012-11-27 21:02:07 +01:00
it 'renders html content' do
subject.render('index', html_types, binding).should match('success')
2012-11-26 20:07:37 +01:00
end
2012-11-27 21:02:07 +01:00
it 'returns a tilt template for different types' do
subject.render('index', json_types, binding).should be_kind_of(String)
end
2012-11-26 20:07:37 +01:00
2012-11-27 21:02:07 +01:00
it 'renders json content' do
subject.render('index', json_types, binding).should match("{text: 'success'}")
2012-11-26 20:07:37 +01:00
end
end