Sha256: b9a6967f849723ad3bc227705684687ad691eadb25a00c9f102fc6c26766db9c

Contents?: true

Size: 1.7 KB

Versions: 17

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe Alephant::Publisher::RenderMapper do
  let(:component_id) { :foo }
  let(:data) {{ :foo => :bar }}
  let(:path) { File.join(File.dirname(__FILE__), 'fixtures/components') }

  subject { Alephant::Publisher::RenderMapper }

  before(:each) do
    File.stub(:directory?).and_return(true)
  end

  describe "initialize(view_base_path)" do
    context "view_base_path = invalid_path" do
      it "should raise InvalidViewPath" do
        File.stub(:directory?).and_return(false)
        expect {
          subject.new(component_id, './invalid_path')
        }.to raise_error(
          'Invalid path'
        )
      end
    end

    context "view_base_path = '.'" do
      it "sets base_path" do
        expect(
          subject.new(component_id, '.').base_path
        ).to eq("./#{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::Publisher::RenderMapper::DEFAULT_LOCATION)
      end
    end
  end

  describe "create_renderer(template_file, data)" do
    it "Returns a valid renderer" do
      expect(
        subject.new(component_id, path)
          .create_renderer('foo', { :content => 'hello'})
      ).to be_a(Alephant::Renderer::Mustache)
    end

    it "Returns expected rendered content from a render" do
      expect(
        subject.new(component_id, path)
          .create_renderer('foo', { :content => 'hello'}).render
      ).to eq("hello\n")
    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(2)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
alephant-publisher-0.2.5 spec/render_mapper_spec.rb
alephant-publisher-0.2.4 spec/render_mapper_spec.rb
alephant-publisher-0.2.3 spec/render_mapper_spec.rb
alephant-publisher-0.2.2 spec/render_mapper_spec.rb
alephant-publisher-0.2.1 spec/render_mapper_spec.rb
alephant-publisher-0.2.0 spec/render_mapper_spec.rb
alephant-publisher-0.1.8 spec/render_mapper_spec.rb
alephant-publisher-0.1.7 spec/render_mapper_spec.rb
alephant-publisher-0.1.6 spec/render_mapper_spec.rb
alephant-publisher-0.1.5 spec/render_mapper_spec.rb
alephant-publisher-0.1.4 spec/render_mapper_spec.rb
alephant-publisher-0.1.3 spec/render_mapper_spec.rb
alephant-publisher-0.1.0 spec/render_mapper_spec.rb
alephant-publisher-0.0.4 spec/render_mapper_spec.rb
alephant-publisher-0.0.3 spec/render_mapper_spec.rb
alephant-publisher-0.0.2 spec/render_mapper_spec.rb
alephant-publisher-0.0.1 spec/render_mapper_spec.rb