Sha256: 1e3b86a4432a10ed153486002b6b140486555a9e476b3260b0806d4b8d6e233b

Contents?: true

Size: 992 Bytes

Versions: 2

Compression:

Stored size: 992 Bytes

Contents

require 'test/unit'
require 'smagacor/controller'

module TestData
  Path = 'test/games'
  MockGamePath = Path + '/tictactoe'
  MockGameInfoFile = MockGamePath + '/game.info'
end

class GameInfoTest < Test::Unit::TestCase

  def setup
    @gi = YAML::load( File.open( TestData::MockGameInfoFile ) )
  end

  def test_load_yaml
    assert_instance_of( Smagacor::GameInfo, @gi )
  end

  def test_save_yaml
    assert_equal( @gi, YAML::load( @gi.to_s ) )
  end

  def test_get_class_object
    assert_equal( Test::Unit::TestCase, @gi.get_class_object )
  end

end


class ControllerTest < Test::Unit::TestCase

  def setup
    @c = Smagacor::Controller.new
    @c.gamespath[0..-1] = TestData::Path
    @gi = YAML::load( File.open( TestData::MockGameInfoFile ) )
    @gi.directory = TestData::MockGamePath
  end

  def test_load_games
    @c.load_games
    assert_equal( @c.games[0], @gi )
    @c.load_games
    assert_equal( @c.games[0], @gi )
    assert_equal( 1, @c.games.length )
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smagacor-0.0.2 test/smagacor/tc_controller.rb
smagacor-0.0.1 test/smagacor/tc_controller.rb