Sha256: 8c01c18b9b84cdd724ee20cdc2f49418a1fb09da247b6065b5be86ee1f56c2bd

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

describe Grid do
  it 'should be empty when created' do
    # given
    expected_contents = [
      [0, 0, 0],
      [0, 0, 0]
    ]
    grid = Grid.new(2, 3)

    # when
    contents = grid.contents

    # then
    contents.should == expected_contents
  end

  it 'should compare equal based on its contents' do
    # given
    grid1 = Grid.new(2, 3)
    grid2 = Grid.new(2, 3)

    # then
    grid1.should == grid2
  end

  it 'should be able to replace its contents' do
    # given
    grid = Grid.new(2,2)
    new_contents = [[0,1,0], [1,0,1]]

    # when
    grid.contents = new_contents

    # then
    grid.contents.should == new_contents
    grid.rows.should == 2
    grid.columns.should == 3
  end

  it 'should add an organism' do
    # given
    grid = Grid.new(2, 2)
    expected = Grid.new(2, 2)
    expected.contents = [[1,0],[0,0]]

    # when
    grid.create_at(0,0)

    # then
    grid.should == expected
  end

  it 'should create itself from a string' do
    # given
    expected = Grid.new 3, 3
    expected.create_at(0,0)
    expected.create_at(1,0)
    expected.create_at(2,2)

    # when
    actual = Grid.from_string "X.. X.. ..X"

    # then
    actual.should == expected
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picolena-0.1.6 rails_plugins/rspec/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb
picolena-0.1.7 rails_plugins/rspec/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb
picolena-0.1.8 rails_plugins/rspec/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb