Sha256: 995782336f356ca4449a09ef911b5d166ea253f4dbab2a1404aa042476174a7d

Contents?: true

Size: 1.31 KB

Versions: 15

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'
require 'wlang/dummy'
module WLang
  describe Dummy do

  def dummy(tpl, scope = {})
    Dummy.render(tpl, scope)
  end

  it 'returns the string when no tag at all' do
    dummy("Hello world!").should eq("Hello world!")
  end

  it 'does not evaluate tags' do
    dummy("Hello ${who}!").should eq("Hello ${who}!")
  end

  it 'does not eat other blocks either' do
    dummy("Hello ${who}{ and more}!").should eq("Hello ${who}{ and more}!")
  end

  it 'keep single braces in peace' do
    dummy("Hello {who}!").should eq("Hello {who}!")
  end

  context "documentation" do
    let(:d){
      dialect do
        def dollar(buf, fn)
          buf << evaluate(fn)
        end
        def no_wlang(buf, fn)
          buf << render(fn)
        end
        tag '$', :dollar
        tag '%', [WLang::Dummy], :no_wlang
      end
    }
    let(:tpl){%q{
      Hello ${who}! This is wlang, a templating language which comes with
      special tags such as %{${who}, +{who}, *{authors}{...}, etc.}
    }.gsub(/^\s*/m,"").strip}
    let(:expected){%q{
      Hello world! This is wlang, a templating language which comes with
      special tags such as ${who}, +{who}, *{authors}{...}, etc.
    }.gsub(/^\s*/m,"").strip}
    specify{ d.render(tpl, :who => "world").should eq(expected) }
  end

  end # describe Dummy
end # module WLang

Version data entries

15 entries across 15 versions & 1 rubygems

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