Sha256: 84c201b468c8e2573ddf960de814ec27a744257cdb278622056098c5a0de8149

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'woyo/world/character'
require 'woyo/world/world'
require 'woyo/world/location'

describe Woyo::Character do

  it 'accepts world for parameter context:' do
    wo = nil
    expect { wo = Woyo::Character.new(:my_id, context: Woyo::World.new) }.to_not raise_error
    wo.context.should be_instance_of Woyo::World
  end

  it 'accepts location for parameter context:' do
    wo = nil
    expect { wo = Woyo::Character.new(:my_id, context: Woyo::Location.new(:here)) }.to_not raise_error
    wo.context.should be_instance_of Woyo::Location
    wo.context.id.should eq :here
  end

  it 'can go way' do
    world = Woyo::World.new do
      location :home do
        way :out do
          to :away
        end
        character :tom
      end
      location :away do
      end
    end
    home = world.locations[:home]
    away = world.locations[:away]
    tom = home.characters[:tom]
    tom.location.should be home
    tom.go :out
    tom.location.should be away
    home.characters[:tom].should be_nil
    away.characters[:tom].should eq tom
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woyo-world-0.0.1 spec/woyo/world/character_spec.rb
woyo-world-0.0.1.pre2 spec/woyo/world/character_spec.rb