Sha256: 3373da99ece6def06e4a39fd6a4ce1abacd97c0bfd59f28ebc79dc6931434118

Contents?: true

Size: 1.07 KB

Versions: 1

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.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| Volt::ContentBinding.new(page, target, context, id, Proc.new { 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

1 entries across 1 versions & 1 rubygems

Version Path
volt-0.8.15 spec/page/bindings/content_binding_spec.rb