spec/lib/hotcell/node/command_spec.rb in hotcell-0.0.1 vs spec/lib/hotcell/node/command_spec.rb in hotcell-0.1.0
- old
+ new
@@ -1,19 +1,19 @@
require 'spec_helper'
describe Hotcell::Command do
let(:context) { Hotcell::Context.new }
- describe 'complex parsing and rendering' do
+ context 'complex parsing and rendering' do
def parse source
Hotcell::Template.parse(source)
end
let(:include_tag) do
Class.new(described_class) do
def validate!
- raise Hotcell::Errors::ArgumentError.new('Template path is required') if children.count != 1
+ raise Hotcell::ArgumentError.new('Template path is required', *position_info) if children.count != 1
end
def process context, path
"included #{path}"
end
@@ -22,14 +22,16 @@
before { Hotcell.stub(:commands) { { 'include' => include_tag } } }
before { Hotcell.stub(:blocks) { {} } }
before { Hotcell.stub(:subcommands) { {} } }
+ specify { expect { parse("{{ include }}").syntax }.to raise_error Hotcell::ArgumentError }
specify { parse("{{ include 'template/path' }}").render(context).should == 'included template/path' }
- specify { expect {
- parse("{{ include }}").syntax
- }.to raise_error Hotcell::Errors::ArgumentError }
+ specify { parse("{{ include 'template/path' }}").render.should == 'included template/path' }
+ specify { parse("{{! include 'template/path' }}").render.should == '' }
+ specify { parse("{{ res = include 'template/path' }} {{ res }}").render.should == 'included template/path included template/path' }
+ specify { parse("{{! res = include 'template/path' }} {{ res }}").render.should == ' included template/path' }
end
describe '#render' do
let(:command) do
Class.new(described_class) do
@@ -38,34 +40,8 @@
end
end
end
specify { command.new('include').render(context).should =~ /ArgumentError/ }
- specify { command.new('include', mode: :silence).render(context).should =~ /ArgumentError/ }
specify { command.new('include', 'path').render(context).should == "rendered path" }
- specify { command.new('include', 'path', mode: :silence).render(context).should == '' }
-
- context 'assigning' do
- before { subject.render(context) }
-
- context do
- subject { command.new('include', assign: 'inclusion') }
- specify { context.key?('inclusion').should be_false }
- end
-
- context do
- subject { command.new('include', mode: :silence, assign: 'inclusion') }
- specify { context.key?('inclusion').should be_false }
- end
-
- context do
- subject { command.new('include', 'path', assign: 'inclusion') }
- specify { context['inclusion'].should == "rendered path" }
- end
-
- context do
- subject { command.new('include', 'path', mode: :silence, assign: 'inclusion') }
- specify { context['inclusion'].should == "rendered path" }
- end
- end
end
end