Sha256: 22baffcd975867d2f46305f65b1b58f32c65c063f1dd1bb3ec12c016206872b3
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe Hotcell::Commands::Include do def parse source Hotcell::Template.parse(source) end let(:resolver_class) do Class.new(Hotcell::Resolver) do attr_reader :templates def initialize templates @templates = templates.stringify_keys end def resolve path, context = nil templates[path] or raise 'Template not found' end end end let(:templates) { { template1: 'Hello', template2: 'Hello, {{ name }}', template3: '{{ name }} - {{ action }}' } } let(:resolver) { resolver_class.new templates } let(:render_options) { { shared: { resolver: resolver } } } describe '#render' do specify { parse("{{ include 'template0' }}").render(render_options).should =~ /Template not found/ } specify { parse("{{ include 'template1' }}").render(render_options).should == 'Hello' } specify { parse("{{ include 'template2' }}").render(render_options).should == 'Hello, ' } specify { parse( "{{ include 'template2', name: 'Pyrosha' }}" ).render(render_options).should == 'Hello, Pyrosha' } specify { parse( "{{! name = Pyrosha; action = 'CRUSH!' }}{{ include 'template3', name: 'Hulk' }}" ).render(render_options).should == 'Hulk - CRUSH!' } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hotcell-0.2.0 | spec/lib/hotcell/commands/include_spec.rb |
hotcell-0.1.0 | spec/lib/hotcell/commands/include_spec.rb |