Sha256: 726d14a6578483be613a5574e8d3fea5f3f37e70ade495318ec3e224dcff0989

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'
require 'volt/page/bindings/content_binding'
require 'volt/page/targets/attribute_target'
require 'volt/page/template_renderer'


describe ContentBinding do  
  it "should render the content in a content binding" do
    dom = AttributeTarget.new(0)
    context = {:name => 'jimmy'}
    binding = ContentBinding.new(nil, dom, context, 0, Proc.new { self[:name] })
    
    expect(dom.to_html).to eq('jimmy')
  end
  
  it "should render with a template" do
    context = {:name => 'jimmy'}
    binding = lambda {|page, target, context, id| ContentBinding.new(page, target, context, id, Proc.new { self[:name] }) }

    templates = {
      'home/index' => {
        'html' => 'hello <!-- $1 --><!-- $/1 -->',
        'bindings' => {1 => [binding]}
      }
    }

    page = double('page')
    expect(page).to receive(:templates).and_return(templates)

    dom = AttributeTarget.new(0)
    
    TemplateRenderer.new(page, dom, context, 'main', 'home/index')
    
    expect(dom.to_html).to eq('hello jimmy')
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
volt-0.6.5 spec/page/bindings/content_binding_spec.rb
volt-0.6.4 spec/page/bindings/content_binding_spec.rb
volt-0.6.3 spec/page/bindings/content_binding_spec.rb
volt-0.6.2 spec/page/bindings/content_binding_spec.rb
volt-0.6.1 spec/page/bindings/content_binding_spec.rb
volt-0.6.0 spec/page/bindings/content_binding_spec.rb