Sha256: 3a6a7a5d6b38d93347b7380236255a2ec760ee6b69e9e2763a6a594550030c07

Contents?: true

Size: 993 Bytes

Versions: 8

Compression:

Stored size: 993 Bytes

Contents

require 'test/unit'
require 'rubygems'
require 'wunderbar'

class BuilderTest < Test::Unit::TestCase
  def test_empty
    x = Wunderbar::XmlMarkup.new :indent => 2
    x.tag!(:script) { x.indented_text! '' }
    assert_equal %{<script>\n</script>\n}, x.target!
  end

  def test_unindented_input
    x = Wunderbar::XmlMarkup.new :indent => 2
    x.tag!(:script) { x.indented_text! "{\n  x: 1\n}" }
    assert_equal %{<script>\n  {\n    x: 1\n  }\n</script>\n}, x.target!
  end

  def test_indented_input
    x = Wunderbar::XmlMarkup.new :indent => 2
    x.tag!(:script) { x.indented_text! "      alert('danger');" }
    assert_equal %{<script>\n  alert('danger');\n</script>\n}, x.target!
  end

  def test_exception
    x = Wunderbar::XmlMarkup.new :indent => 2
    x.tag!(:body) do
      begin
        x.tag!(:p) { raise Exception.new('boom') }
      rescue Exception => e
        x.tag!(:pre, e)
      end
    end
    assert x.target!.include? '<p>' and x.target!.include? '</p>'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wunderbar-0.8.13 test/test_builder.rb
wunderbar-0.8.12 test/test_builder.rb
wunderbar-0.8.11 test/test_builder.rb
wunderbar-0.8.10 test/test_builder.rb
wunderbar-0.8.9 test/test_builder.rb
wunderbar-0.8.8 test/test_builder.rb
wunderbar-0.8.7 test/test_builder.rb
wunderbar-0.8.6 test/test_builder.rb