Sha256: 7af99abd4f998d0ab7e7728f486376c60cf15892eee979753faa61e09378635b

Contents?: true

Size: 526 Bytes

Versions: 3

Compression:

Stored size: 526 Bytes

Contents

require 'test/unit'
require 'html/template/pro'

class TestRandom < Test::Unit::TestCase
  def test_random
    text = %{<TMPL_IF foo>YES<TMPL_ELSE>NO</TMPL_IF>}

    template = HTML::Template::Pro.new(:scalarref => text)
    template.param(:foo) do
      rand(2).to_i == 0 ? false : true
    end
    before, changed = template.output, false
    200.times do
      r = template.output
      changed = true if before != r
      assert((r == 'YES' || r == 'NO'))
      before = r
    end
    assert(changed, 'changed')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
html-template-pro-0.0.3 test/test_random.rb
html-template-pro-0.0.2 test/test_random.rb
html-template-pro-0.0.1 test/test_random.rb