class TestWabisabiGenerator

Public Instance Methods

ok(e, s) click to toggle source
# File vendor/qwik/lib/qwik/wabisabi-generator.rb, line 81
def ok(e, s)
  assert_equal e, s
end
test_all() click to toggle source
# File vendor/qwik/lib/qwik/wabisabi-generator.rb, line 85
def test_all
  g = Qwik::WabisabiGenerator.new

  # test_htree_generator
  ok([:p], g.p)
  ok([:a], g.a)
  ok([:b], g.b{})
  ok([:b, ''], g.b{''})
  ok([:img, {:src=>'u'}], g.img(:src=>'u'))
  ok([:b, 't'], g.b{'t'})
  ok([:p, [:b, 'b']], g.p{g.b{'b'}})
  ok([:p, 't', [:p, 'b'], 't'], g.p{['t', g.p{'b'}, 't']})
  ok([:a, {:href=>'u'}, 't'], g.a(:href=>'u'){'t'})
  ok([:font, {:size=>'7'}, 't'], g.font(:size=>'7'){'t'})

  # test_namespace
  ok([:b, 't'], g.make('b'){'t'}) 
  ok([:'n:b', 't'], g.make('n:b'){'t'})
  ok([:a, {:href=>'u'}, 't'], g.make('a', :href=>'u'){'t'})
  html = g.html {[
      g.head {[
          g.title {"タイトル"},
        ]},
      g.body {[
          g.pre {[g.b {'world'},  'hello']},
          g.pre {['this is ', g.b{'bold'}, ' text.']},
          g.pre {['this is ', g.i{'italic'}, ' text.']},
          g.p {['this is ', g.a(:href=>'hoge'){'anchor'}, ' text.']},
        ]}
    ]}
  ok([:html,
       [:head, [:title, "タイトル"]],
       [:body,
         [:pre, [:b, 'world'], 'hello'],
         [:pre, 'this is ', [:b, 'bold'], ' text.'],
         [:pre, 'this is ', [:i, 'italic'], ' text.'],
         [:p, 'this is ', [:a, {:href=>'hoge'}, 'anchor'], ' text.']]],
     html)

  # test_with_underbar
  ok([:ab], g.ab)
  ok([:'a-b'], g.make('a-b'))

  # test_ordered_hash
  ok([:a, {'b'=>'c'}], g.a({'b'=>'c'}))
  ok([:a, {'b'=>'c'}], g.a([{'b'=>'c'}]))
  ok([:a, {'b'=>'c'}, {'d'=>'e'}], g.a([{'b'=>'c'}, {'d'=>'e'}]))
  ok([:a, {'b'=>'c'}, {'d'=>'e'}], g.a({'b'=>'c'}, {'d'=>'e'}))
end