Sha256: 558fca1398c36485e2d1974e8345c5f6dc561506067390718fe64f1a67f06fc9

Contents?: true

Size: 894 Bytes

Versions: 15

Compression:

Stored size: 894 Bytes

Contents

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

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

    it 'invokes to_s' do
      s = Struct.new(:to_s).new("World")
      render("!{hello}", {:hello => s}).should eq("World")
    end

    it 'works with Numbers' do
      render("!{hello}", {:hello => 12}).should eq("12")
    end

    it 'does not escape html' do
      render("!{hello}", {:hello => "<script>"}).should eq("<script>")
    end

    it 'is not too sensitive to spacing' do
      render("!{ hello }", {:hello => "World"}).should eq("World")
    end

    it 'supports a binding' do
      hello = "World"
      render("!{hello}", binding).should eq("World")
    end

    it 'supports chain invocations' do
      s = Struct.new(:hello).new("World")
      render("!{s.hello}", binding).should eq("World")
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

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