Sha256: 7887567d0d9d48d6f2c53a3c3cfe9d85b17941aca12ba114b3b1b75ccfe89450
Contents?: true
Size: 1.3 KB
Versions: 9
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' class ::TestIfBindingController < Volt::ModelController model :page end describe Volt::IfBinding do it 'should render an if' do dom = Volt::AttributeTarget.new(0) context = ::TestIfBindingController.new(volt_app) context._name = 'jimmy' branches = [ [ proc { _name == 'jimmy' }, 'main/if_true' ], [ nil, 'main/if_false' ] ] binding = ->(volt_app, target, context, id) do Volt::IfBinding.new(volt_app, target, context, 0, branches) end templates = { 'main/main' => { 'html' => 'hello <!-- $1 --><!-- $/1 -->', 'bindings' => { 1 => [binding] } }, 'main/if_true' => { 'html' => 'yes, true', 'bindings' => {} }, 'main/if_false' => { 'html' => 'no, false', 'bindings' => {} } } page = double('volt/page') expect(page).to receive(:templates).and_return(templates).at_least(1).times volt_app = double('volt/app') expect(volt_app).to receive(:page).and_return(page).at_least(1).times Volt::TemplateRenderer.new(volt_app, dom, context, 'main', 'main/main') expect(dom.to_html).to eq('yes, true') context._name = 'bob' Volt::Computation.flush! expect(dom.to_html).to eq('no, false') end end
Version data entries
9 entries across 9 versions & 1 rubygems