diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/node_spec.rb | 12 | ||||
| -rw-r--r-- | spec/spec_helper.rb | 11 |
2 files changed, 23 insertions, 0 deletions
diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 1612510..3aaec55 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -192,6 +192,18 @@ describe Zorglub do expect(Node3.after).to eq 0 end + it 'partial with locals should work' do + expect(Node0.partial(:test_locals, locals: { my_local: 'hello' })).to eq 'hello' + end + + it 'recursive partial should work' do + expect(Node0.partial(:test_recursive, 3)).to eq '3-2-1-end' + end + + it 'recursive partial depth limit should be enforced' do + expect { Node0.partial(:test_recursive, 25) }.to raise_error('Recursive partial depth limit exceeded') + end + it 'static pages should be generated' do r = Node6.my_call '/do_static' expect(r[2][0]).to eq 'VAL 1' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a9415df..b81f0cf 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -118,6 +118,17 @@ class Node0 < Zorglub::Node engine! :sass end end + + def test_locals + @my_local + end + + def test_recursive(val) + val = val.to_i + return 'end' if val <= 0 + + "#{val}-" + partial(:test_recursive, val - 1) + end end class Node1 < Zorglub::Node |
