Sha256: f6efaedd9e690bb5da1f1fd0dc10f6009f18054adc2949a8c45546cc167dd63b

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require File.dirname(__FILE__) + '/helper'

class FlameBuilderTest < Test::Unit::TestCase
  def setup
    @s = ""
    @b = Tracksperanto::FlameBuilder.new(StringIO.new(@s))
  end
  
  def test_write_loose
    @b.write_loose("Foo")
    assert_equal "Foo\n", @s
  end

  def test_write_tuple
    @b.write_tuple("Foo", 3)
    assert_equal "Foo 3\n", @s
  end

  def test_write_tuple_with_true
    @b.write_tuple("Foo", true)
    assert_equal "Foo yes\n", @s
  end

  def test_write_tuple_with_false
    @b.write_tuple("Foo", false)
    assert_equal "Foo no\n", @s
  end
  
  def test_write_block
    @b.write_block("Foo", 1) do | b |
      b.write_tuple("Baz", 2)
    end
    assert_equal "Foo 1\n\tBaz 2\n\tEnd\n", @s
  end
  
  def test_automissing_with_values
    @b.some_key(2)
    assert_equal "SomeKey 2\n", @s
  end

  def test_automissing_with_block
    @b.some_key(2) do | b |
      b.some_subkey
    end
    assert_equal "SomeKey 2\n\tSomeSubkey\n\tEnd\n", @s
  end
  
  def test_linebreak
    @b.linebreak!(5)
    assert_equal "\n" * 5, @s
  end
  
  def test_color_hash
    @b.color_hash!(:triplet, 10, 12, 15)
    assert_equal "Triplet\n\tRed 10\n\tGreen 12\n\tBlue 15\n", @s
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracksperanto-1.8.0 test/test_flame_builder.rb