fedora-migrator /vendor/gems/facets-2.4.5/test/more/test_buildable.rb

Language Ruby Lines 74
MD5 Hash 4009c3db9a83298d1972aae5c672a519 Estimated Cost $1,187 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Test facets/buildable.rb

require 'facets/buildable.rb'
require 'test/unit'

class TestBuildable < Test::Unit::TestCase

  module M
    include Buildable

    extend self

    def m(n,*m) ; "#{n}{#{m}}"; end
    def t(n) ; "#{n}"; end

    alias :build :m
  end

  def test_01
    str = M.build do
      html do
        head do
          title "Test"
        end
        body do
          i "Hello"
          build! :not
          t "Test"
          t "Hey"
        end
      end
    end

    r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"

    assert_equal( r, M.builder.to_s )
  end

end

#

class TestBuildingBlock < Test::Unit::TestCase

  module M
    extend self
    def m(n,*m) ; "#{n}{#{m}}"; end
    def t(n) ; "#{n}"; end
  end

  def test_01
    build = BuildingBlock.new(M, :m)

    build.html do
      head do
        title "Test"
      end

      body do
        i "Hello"
        build! :not
        t "Test"
        t "Hey"
      end
    end

    r = "html{head{title{Test}}body{i{Hello}not{}TestHey}}"

    assert_equal( r, build.to_s )
  end

end
Back to Top