Sha256: 3c83667035217a826d66690056d63f6b92a2441a1788b6080fde2db8e28c97dc

Contents?: true

Size: 1.07 KB

Versions: 36

Compression:

Stored size: 1.07 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 Volt::ContentBinding do
  it 'should render the content in a content binding' do
    dom = Volt::AttributeTarget.new(0)
    context = { name: 'jimmy' }
    binding = Volt::ContentBinding.new(nil, dom, context, 0, proc { 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| Volt::ContentBinding.new(page, target, context, id, proc { self[:name] }) }

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

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

    dom = Volt::AttributeTarget.new(0)

    Volt::TemplateRenderer.new(page, dom, context, 'main', 'main/main')

    expect(dom.to_html).to eq('hello jimmy')
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
volt-0.9.1 spec/page/bindings/content_binding_spec.rb
volt-0.9.1.pre5 spec/page/bindings/content_binding_spec.rb
volt-0.9.1.pre4 spec/page/bindings/content_binding_spec.rb
volt-0.9.1.pre3 spec/page/bindings/content_binding_spec.rb
volt-0.9.1.pre2 spec/page/bindings/content_binding_spec.rb
volt-0.9.1.pre1 spec/page/bindings/content_binding_spec.rb
volt-0.9.0 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre7 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre6 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre5 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre4 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre3 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre2 spec/page/bindings/content_binding_spec.rb
volt-0.9.0.pre1 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta9 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta8 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta7 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta6 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta5 spec/page/bindings/content_binding_spec.rb
volt-0.8.27.beta4 spec/page/bindings/content_binding_spec.rb