Sha256: 6506bc845beb0e791a93214433c9a771081b7670f45f8ba71d1a9bb69f2072b0

Contents?: true

Size: 847 Bytes

Versions: 1

Compression:

Stored size: 847 Bytes

Contents

require 'rodakase/view/renderer'

RSpec.describe Rodakase::View::Renderer do
  subject(:renderer) do
    Rodakase::View::Renderer.new(SPEC_ROOT.join('fixtures/templates'), engine: :slim)
  end

  let(:scope) { double(:scope) }

  describe '#call' do
    it 'renders template' do
      expect(renderer.('hello', scope)).to eql('<h1>Hello</h1>')
    end

    it 'looks up shared template in current dir' do
      expect(renderer.('_shared_hello', scope)).to eql('<h1>Hello</h1>')
    end

    it 'looks up shared template in upper dir' do
      expect(renderer.chdir('greetings').('_shared_hello', scope)).to eql('<h1>Hello</h1>')
    end

    it 'raises error when template was not found' do
      expect {
        renderer.('not_found', scope)
      }.to raise_error(Rodakase::View::Renderer::TemplateNotFoundError, /not_found/)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rodakase-0.0.1 spec/unit/view/renderer_spec.rb