Sha256: a8a17400343cc3ea4525718982dccbcfe7671fde580c8892fd5f982aad3b65f4

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

require 'spec_helper'
require 'abstracta'

include Abstracta

describe Territory do
  subject { Territory.new([[0,0]]) }

  it 'should have dna' do
    expect(subject.dna).to be_a OpenStruct
  end

  describe "#step" do
    it "should age occupants" do
      expect { subject.step }.to change { subject.first.age }.by 1
    end

    let(:cycle) { subject.dna.growth.cycle }

    it "should grow total size" do
      expect { cycle.times { subject.step } }.to change { subject.size }.by(subject.growth.to_i)
    end

    context "longterm growth behaviors" do
      before { cycle.times { subject.step }}

      it 'should generate occupants with valid positions' do
	subject.occupants.each do |occupant|
	  expect(occupant.x).to be_an(Integer)
	  expect(occupant.y).to be_an(Integer)
	end
      end

      it "should grow a little bit" do
	expect(subject.size).to be > 1
      end

      it "should not grow too much" do
	expect(subject.size).not_to be > subject.dna.growth.limit
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
abstracta-0.1.1 spec/abstracta/territory_spec.rb