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.1.0 spec/octopolo/renderer_spec.rb
octopolo-1.0.2 spec/octopolo/renderer_spec.rb
octopolo-1.0.1 spec/octopolo/renderer_spec.rb
octopolo-1.0.0 spec/octopolo/renderer_spec.rb
octopolo-0.4.1 spec/octopolo/renderer_spec.rb
octopolo-0.4.0 spec/octopolo/renderer_spec.rb
octopolo-0.3.6 spec/octopolo/renderer_spec.rb
octopolo-0.3.5 spec/octopolo/renderer_spec.rb
octopolo-0.3.4 spec/octopolo/renderer_spec.rb
octopolo-0.3.3 spec/octopolo/renderer_spec.rb
octopolo-0.3.2 spec/octopolo/renderer_spec.rb
octopolo-0.3.1 spec/octopolo/renderer_spec.rb
octopolo-0.3.0 spec/octopolo/renderer_spec.rb
octopolo-0.2.1 spec/octopolo/renderer_spec.rb
octopolo-0.1.4 spec/octopolo/renderer_spec.rb
octopolo-0.2.0 spec/octopolo/renderer_spec.rb
octopolo-0.1.3 spec/octopolo/renderer_spec.rb
octopolo-0.1.2 spec/octopolo/renderer_spec.rb
octopolo-0.1.1 spec/octopolo/renderer_spec.rb
octopolo-0.1.0 spec/octopolo/renderer_spec.rb