Sha256: 4c4af4105c6cbcbe52d68637d9520309944bee70b1c01912fad6351c031b0ba9

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Alephant::Renderer::ViewMapper do
  let(:renderer_id) { 'foo-renderer' }
  let(:data) { { foo: :bar } }
  let(:path) { File.join(File.dirname(__FILE__), 'fixtures/components') }

  subject { Alephant::Renderer::ViewMapper }

  describe 'initialize(view_base_path)' do
    context 'view_base_path = invalid_path' do
      it 'should raise an error' do
        expect do
          subject.new(renderer_id, './invalid_path')
        end.to raise_error ::Alephant::Renderer::Error::InvalidBasePath
      end
    end

    context 'view_base_path = .' do
      it 'sets base_path' do
        expect(
          subject.new(renderer_id, path).base_path
        ).to eq("#{path}/#{renderer_id}")
      end
    end

    context 'view_base_path = nil' do
      it 'sets base_path' do
        expect(
          subject.new(renderer_id).base_path
        ).to eq(Alephant::Renderer::ViewMapper::DEFAULT_LOCATION)
      end
    end
  end

  describe 'generate(data)' do
    it 'calls create_renderer for each template found' do
      expect(
        subject.new(renderer_id, path).generate(data).size
      ).to eq(4)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-renderer-3.1.0 spec/view_mapper_spec.rb