Sha256: ff0ebbd3c40d60e12eb461855ec4e0710c39b7e6f99cc566e3dc5fd18081ced6

Contents?: true

Size: 1.91 KB

Versions: 31

Compression:

Stored size: 1.91 KB

Contents

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

class TrackerTest < Test::Unit::TestCase
  
  def test_supports_block_init
    t = Tracksperanto::Tracker.new do |t| 
      t.name = 'Foo'
    end
    assert_equal "Foo", t.name
  end
  
  def test_responds_to_needed_methods
    t = Tracksperanto::Tracker.new
    assert_respond_to t, :name
    assert_respond_to t, :each
    assert_respond_to t, :keyframes
  end
  
  def test_properly_ignores_flattening
    t = []
    t << Tracksperanto::Tracker.new(:name => "Abc")
    t[-1].keyframe! :abs_x => 12, :abs_y => 23, :frame => 1
    t[-1].keyframe! :abs_x => 13, :abs_y => 24, :frame => 2
    
    t << Tracksperanto::Tracker.new(:name => "Cde")
    t[-1].keyframe! :abs_x => 12, :abs_y => 23, :frame => 1
    t[-1].keyframe! :abs_x => 13, :abs_y => 24, :frame => 2
    
    assert_kind_of Tracksperanto::Tracker, t.flatten[0]
    assert_equal 2, t.flatten.length
  end
  
  def test_supports_hash_init
    assert_equal "Foo", Tracksperanto::Tracker.new(:name => "Foo").name
  end
  
  def test_supports_hash_init_with_keyframes
    assert_equal [1,2], Tracksperanto::Tracker.new(:keyframes => [1,2]).keyframes
  end
  
  def test_supports_array_methods
    t = Tracksperanto::Tracker.new(:keyframes => [1,2])
    assert_equal [1,2], t.to_a
    assert_equal 2, t.length
    t.push(3)
    assert_equal 3, t.length
    assert_equal [1,2,3], t.to_a
  end
    
  def test_inspect
    t = Tracksperanto::Tracker.new(:name => "FooTracker")
    assert_equal '<T "FooTracker" with 0 keyframes>', t.inspect
  end
  
  def test_ensure_tracker_forbids_spaces_in_names
    t = Tracksperanto::Tracker.new(:name => "Mary had a \n \t little lamb")
    assert_equal "Mary_had_a_little_lamb", t.name
  end
  
  def test_enumerates_keyframe_values_and_returns_length
    t = Tracksperanto::Tracker.new(:keyframes => [:a, :b])
    assert_equal [:a, :b], t.map{|e| e}
    assert_equal 2, t.length
    assert_equal :a, t[0]
  end
  
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
tracksperanto-2.0.1 test/test_tracker.rb
tracksperanto-2.0.0 test/test_tracker.rb
tracksperanto-1.9.9 test/test_tracker.rb
tracksperanto-1.9.8 test/test_tracker.rb
tracksperanto-1.9.6 test/test_tracker.rb
tracksperanto-1.9.5 test/test_tracker.rb
tracksperanto-1.9.4 test/test_tracker.rb
tracksperanto-1.9.3 test/test_tracker.rb
tracksperanto-1.9.2 test/test_tracker.rb
tracksperanto-1.9.1 test/test_tracker.rb
tracksperanto-1.9.0 test/test_tracker.rb
tracksperanto-1.8.4 test/test_tracker.rb
tracksperanto-1.8.2 test/test_tracker.rb
tracksperanto-1.8.1 test/test_tracker.rb
tracksperanto-1.8.0 test/test_tracker.rb
tracksperanto-1.7.5 test/test_tracker.rb
tracksperanto-1.7.4 test/test_tracker.rb
tracksperanto-1.7.3 test/test_tracker.rb
tracksperanto-1.7.2 test/test_tracker.rb
tracksperanto-1.7.1 test/test_tracker.rb