Sha256: 0dbd0a67bec98a65135f87cef8782c3dd7980bc0a9d586e687ffde6f178886d7

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
require 'volt/page/bindings/content_binding'
require 'volt/page/targets/attribute_target'
require 'volt/page/targets/dom_section'
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

4 entries across 4 versions & 1 rubygems

Version Path
volt-0.7.5 spec/page/bindings/content_binding_spec.rb
volt-0.7.4 spec/page/bindings/content_binding_spec.rb
volt-0.7.3 spec/page/bindings/content_binding_spec.rb
volt-0.7.2 spec/page/bindings/content_binding_spec.rb