Sha256: be95946b25f42ea4b0413f349b6445800352b1a4ec54f8ca018156bbd09c2503

Contents?: true

Size: 1.13 KB

Versions: 42

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"
require_relative "../../lib/octopolo/renderer"

module Octopolo
  describe Renderer do
    context ".render template, locals" do
      let(:locals) { {foo: "bar"} }
      let(:template_name) { "some_template" }
      let(:template_contents) { "<%= foo %>" }

      it "renders the given template name with the given local variables" do
        Renderer.should_receive(:contents_of).with(template_name) { template_contents }
        rendered = Renderer.render(template_name, locals)
        rendered.should == locals[:foo]
      end
    end

    context ".template_base_path" do
      it "should be in the octopolo directory" do
        Renderer.template_base_path.should == File.expand_path(File.join(__FILE__, "../../../lib/octopolo/templates"))
      end
    end

    context ".contents_of template" do
      let(:contents) { stub(:erb) }
      let(:name) { "some_template" }
      let(:path) { File.join(Renderer.template_base_path, "#{name}.erb") }

      it "reads the file from templates/" do
        File.should_receive(:read).with(path) { contents }
        Renderer.contents_of(name).should == contents
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
octopolo-1.12.0 spec/octopolo/renderer_spec.rb
octopolo-1.11.4 spec/octopolo/renderer_spec.rb
octopolo-1.11.3 spec/octopolo/renderer_spec.rb
octopolo-1.11.1 spec/octopolo/renderer_spec.rb
octopolo-1.11.0 spec/octopolo/renderer_spec.rb
octopolo-1.9.0 spec/octopolo/renderer_spec.rb
octopolo-1.8.1 spec/octopolo/renderer_spec.rb
octopolo-1.8.0 spec/octopolo/renderer_spec.rb
octopolo-1.7.1 spec/octopolo/renderer_spec.rb
octopolo-1.7.0 spec/octopolo/renderer_spec.rb
octopolo-1.6.0 spec/octopolo/renderer_spec.rb
octopolo-1.5.3 spec/octopolo/renderer_spec.rb
octopolo-1.5.2 spec/octopolo/renderer_spec.rb
octopolo-1.5.1 spec/octopolo/renderer_spec.rb
octopolo-1.5.0 spec/octopolo/renderer_spec.rb
octopolo-1.4.0 spec/octopolo/renderer_spec.rb
octopolo-1.3.0 spec/octopolo/renderer_spec.rb
octopolo-1.2.1 spec/octopolo/renderer_spec.rb
octopolo-1.2.0 spec/octopolo/renderer_spec.rb
octopolo-1.1.1 spec/octopolo/renderer_spec.rb