Sha256: 9ceaafa7aec4686b28fcac90e62152a217e6457831ab60753d08160a862f85e0

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'woyo/world/world_object'

describe Woyo::WorldObject do

  context '#new' do

    it 'initializes with symbol id' do
      expect { Woyo::WorldObject.new :my_id }.to_not raise_error
    end

    it 'creates id' do
      Woyo::WorldObject.new(:my_id).id.should eq :my_id
    end

    it 'converts id to lowercase' do
      Woyo::WorldObject.new(:MY_id ).id.should eq :my_id
    end

    it 'accepts named parameter context:' do
      expect { Woyo::WorldObject.new(:my_id, context: :just_a_test ) }.to_not raise_error
    end

    it 'accepts a block with arity 0' do
      result = ''
      Woyo::WorldObject.new( :home ) { result = 'ok' }
      result.should eq 'ok'
    end

    it 'instance evals block with arity 0' do
      Woyo::WorldObject.new( :home ) { self.class.should == Woyo::WorldObject }
    end

    it 'accepts a block with arity 1' do
      result = ''
      Woyo::WorldObject.new( :home ) { |scope| result = 'ok' }
      result.should eq 'ok'
    end

    it 'passes self to block with arity 1' do
      Woyo::WorldObject.new( :home ) { |scope| scope.should be_instance_of Woyo::WorldObject }
    end

  end

  it 'provides access to context' do
    wo = Woyo::WorldObject.new(:my_id, context: :just_a_test )
    wo.context.should eq :just_a_test
  end

  it 'name attribute defaults to id'

end

Version data entries

2 entries across 2 versions & 1 rubygems

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