summaryrefslogtreecommitdiff
path: root/spec/unit/renderer/render_spec.rb
blob: 6bb780179c5914847c6c5fedb1f0cf475189b999 (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) }
  let(:template_path) { 'foo' }
  let(:file_list) { ['./foo/welcome/index.html.erb'] }

  shared_examples_for 'the rendering' do
    before :each do
      subject.stub(:search_files).and_return(file_list)
      subject.stub(:template).and_return(Tilt[:erb].new {template} )
    end

    it "renders the template" do
      subject.render('welcome/index', 'text/html', binding).should eq(result)
    end
  end

  context 'a simple template' do
    let(:template) { 'success' }
    let(:binding) { Object.new }
    let(:result) { template }

    it_behaves_like 'the rendering'
  end

  context 'a complex template' do
    let(:template) { 'success <%= name %>' }
    let(:binding) { SpecTemplateContext.new('bar') }
    let(:result) { 'success bar' }

    it_behaves_like 'the rendering'
  end
end