Sha256: 21f3e5dbe7207ca1748194a9b932258ebf3e8116402418dc5c35be643093b101

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

describe Alephant::Renderer::ViewMapper do
  let(:component_id) { :foo }
  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 {
          subject.new(component_id, './invalid_path')
        }.to raise_error
      end
    end

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

    context "view_base_path = nil" do
      it "sets base_path" do
        expect(
          subject.new(component_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(component_id, path).generate(data).size
      ).to eq(3)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alephant-renderer-2.0.1 spec/view_mapper_spec.rb
alephant-renderer-2.0.0 spec/view_mapper_spec.rb
alephant-renderer-1.0.5 spec/view_mapper_spec.rb
alephant-renderer-1.0.4 spec/view_mapper_spec.rb
alephant-renderer-1.0.3 spec/view_mapper_spec.rb
alephant-renderer-1.0.2 spec/view_mapper_spec.rb
alephant-renderer-1.0.1 spec/view_mapper_spec.rb
alephant-renderer-1.0.0 spec/view_mapper_spec.rb
alephant-renderer-0.3.0 spec/view_mapper_spec.rb
alephant-renderer-0.2.0 spec/view_mapper_spec.rb
alephant-renderer-0.1.0 spec/view_mapper_spec.rb