Sha256: 359486a7fe69051df8820b0f977d176f9275ec805aed5d0ca3d90b0bef1075bc

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

require File.dirname(__FILE__) + '/spec_helper'

class Foo
end
class FooRenderer
  def render(object)
    "foo renderer"
  end
end
describe SlippersParser do
  
  before(:each) do
    @parser = SlippersParser.new
  end
  
  it 'should return an empty string if the subtemplate does not respond to render' do
    template_group = Slippers::TemplateGroup.new(:templates => {:not_this_one => stub('renderer')})    
    @parser.parse("$not_this_one()$").eval(stub('object'), template_group).should eql('')
  end
    
  it 'should find a renderer based on the type of the object to render' do
    foo = Foo.new
    template_group = Slippers::TemplateGroup.new(:templates => {:foo => FooRenderer.new})    
    @parser.parse("$foo()$").eval(foo, template_group).should eql('foo renderer')
    @parser.parse("$foobar:foo()$").eval({:foobar => foo}, template_group).should eql('foo renderer')
  end    
  
  it 'should find a renderer based on the type of the object to render' do
    foo = Foo.new
    template_group = Slippers::TemplateGroup.new(:templates => {Foo => FooRenderer.new})    
    @parser.parse("$foobar$").eval({:foobar => foo}, template_group).should eql('foo renderer')
  end
end


Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slippers-0.0.14 spec/parse_renderers.rb
slippers-0.0.13 spec/parse_renderers.rb
slippers-0.0.12 spec/parse_renderers.rb
slippers-0.0.11 spec/parse_renderers.rb
slippers-0.0.10 spec/parse_renderers.rb