Sha256: 6500350857481927b5e194741a542ac77adf064e8c833c2597a08947e8b3e047

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

require 'dry/view/renderer'

RSpec.describe Dry::View::Renderer do
  subject(:renderer) do
    Dry::View::Renderer.new(SPEC_ROOT.join('fixtures/templates'), format: 'html', 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(Dry::View::Renderer::TemplateNotFoundError, /not_found/)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-view-0.1.1 spec/unit/renderer_spec.rb
dry-view-0.1.0 spec/unit/renderer_spec.rb