summaryrefslogtreecommitdiff
path: root/spec/unit/renderer/render_spec.rb
blob: a4064da10fa9d2ecf72bcc6707a2f6c42417e438 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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']
  }}
  let(:html_types) { ['text/html'] }
  let(:json_types) { ['application/json'] }
  let(:binding) { SpecTemplateContext.new('foo') }

  before :each do
    subject.read_template_path!
  end

  it 'returns a tilt template' do
    subject.render('index', html_types, binding).should be_kind_of(String)
  end

  it 'renders html content' do
    subject.render('index', html_types, binding).should match('success')
  end

  it 'returns a tilt template for different types' do
    subject.render('index', json_types, binding).should be_kind_of(String)
  end

  it 'renders json content' do
    subject.render('index', json_types, binding).should match("{text: 'success'}")
  end
end