Sha256: d6e186e027a46d9d41abfe5bd3a23f40f9faee39adb07d903dd0420f7ae4b023
Contents?: true
Size: 1.1 KB
Versions: 8
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' module WLang class Source describe FrontMatter, "locals" do let(:template){ nil } subject{ FrontMatter.new(source, template).locals } context 'without front matter' do let(:source){ "Hello world!" } it{ should eq({}) } end context 'with an empty front matter' do let(:source){ "---\n---\nHello world!" } it{ should eq({}) } end describe 'with a front matter' do let(:source){ "---\nlocals:\n x: 2\n---\nHello world!" } specify 'it decode the YAML data' do subject.should eq({"x" => 2}) end end describe 'with a front matter containing partials' do let(:template){ tpl_class = Struct.new(:compiler) tpl_class.new(Object.new.extend(Module.new{ def to_ruby_proc(tpl) tpl.upcase end })) } let(:source){ "---\npartials:\n x: abc\n---\nHello world!" } specify 'it should have correct locals' do subject.should eq({"x" => 'ABC'}) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems