Sha256: 463e245e555f5c8609bfa9f17a92cd724f467c8c738774aee5a4c339d84f29db

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
woyo-world-0.0.6 spec/woyo/world/world_object_spec.rb
woyo-world-0.0.5 spec/woyo/world/world_object_spec.rb
woyo-world-0.0.4 spec/woyo/world/world_object_spec.rb
woyo-world-0.0.3 spec/woyo/world/world_object_spec.rb
woyo-world-0.0.2 spec/woyo/world/world_object_spec.rb