Sha256: e349034161c66a8cff5757a91c53691cc993f643c9729b1104aa12ea6e72eba9

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

require 'rubygems'
require 'test/unit'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'ceml'

class Test::Unit::TestCase
  DRIVER = CEML::Driver.new

  def play script = nil
    @iid = script && DRIVER.start(script)
    yield
    CEML::Driver::JUST_SAID.clear
    CEML::Driver::PLAYERS.clear
    CEML::Driver::INCIDENTS.clear
  end

  def ping s, candidate
    DRIVER.ping s, candidate
  end

  def says id, str
    iid = CEML::Driver::INCIDENTS.keys.find do |iid|
      CEML::Driver::PLAYERS[iid].find{ |p| p[:id] == id }
    end
    DRIVER.post iid, :id => id, :received => str
  end

  def player id, *roles
    DRIVER.post @iid, :id => id, :roles => roles
  end

  def asked id, rx
    assert p = CEML::Driver::JUST_SAID[id]
    assert_equal :ask, p[:said]
    assert_match rx, p[:q]
    CEML::Driver::JUST_SAID.delete id
  end

  def silent id
    assert !CEML::Driver::JUST_SAID[id]
  end

  def told id, rx
    assert p = CEML::Driver::JUST_SAID[id]
    assert_match rx, p[:msg]
    CEML::Driver::JUST_SAID.delete id
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ceml-0.5.5 test/helper.rb
ceml-0.5.4 test/helper.rb
ceml-0.5.3 test/helper.rb
ceml-0.5.2 test/helper.rb
ceml-0.5.1 test/helper.rb