Sha256: 2ae73dd63924d8867c84dbc38f4496f27bd2a0d03f8f94fefc391bd23319c17e

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'wlang/html'
module WLang
  describe Html, "^{...}" do

    debug = Module.new{ def inspect; "lambda{ #{call.inspect} }"; end }

    def render(tpl, scope = {})
      Html.render(tpl, scope, "")
    end

    [
      false,
      nil,
      lambda{ nil   }.extend(debug),
      lambda{ false }.extend(debug)
    ].each do |test|
      context "when #{test.inspect}" do
        it 'renders the then block' do
          render("^{test}{hello}", binding).should eq("hello")
        end
        it 'does not render the else block' do
          render("^{test}{hello}{otherwise}", binding).should eq("hello")
        end
      end
    end

    [
      true,
      "Something",
      [],
      lambda{ true }.extend(debug),
      lambda{ "something" }.extend(debug)
    ].each do |test|
      context "when #{test.inspect}" do
        it 'do not render the then block' do
          render("^{test}{hello}", binding).should eq("")
        end
        it 'renders the else block if present' do
          render("^{test}{hello}{otherwise}", binding).should eq("otherwise")
        end
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
wlang-3.0.1 spec/integration/html/test_caret.rb
wlang-3.0.0 spec/integration/html/test_caret.rb
wlang-2.3.1 spec/integration/html/test_caret.rb
wlang-2.3.0 spec/integration/html/test_caret.rb
wlang-2.2.4 spec/integration/html/test_caret.rb
wlang-2.2.3 spec/integration/html/test_caret.rb
wlang-2.2.2 spec/integration/html/test_caret.rb
wlang-2.2.1 spec/integration/html/test_caret.rb
wlang-2.2.0 spec/integration/html/test_caret.rb
wlang-2.1.2 spec/integration/html/test_caret.rb
wlang-2.1.1 spec/integration/html/test_caret.rb
wlang-2.1.0 spec/integration/html/test_caret.rb
wlang-2.0.1 spec/integration/html/test_caret.rb
wlang-2.0.0 spec/integration/html/test_caret.rb