Sha256: 2fead291a11e4beffae50ea7cc1f35c4681ee2196fe3cb6f9105fb83a7e69fcb

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 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 = ->(volt_app, target, context, id) { Volt::ContentBinding.new(volt_app, 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)

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


    dom = Volt::AttributeTarget.new(0)

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
volt-0.9.4.pre3 spec/page/bindings/content_binding_spec.rb
volt-0.9.4.pre2 spec/page/bindings/content_binding_spec.rb
volt-0.9.4.pre1 spec/page/bindings/content_binding_spec.rb
volt-0.9.3 spec/page/bindings/content_binding_spec.rb
volt-0.9.3.pre6 spec/page/bindings/content_binding_spec.rb
volt-0.9.3.pre5 spec/page/bindings/content_binding_spec.rb
volt-0.9.3.pre4 spec/page/bindings/content_binding_spec.rb
volt-0.9.3.pre3 spec/page/bindings/content_binding_spec.rb
volt-0.9.3.pre2 spec/page/bindings/content_binding_spec.rb