Skip to content

Instantly share code, notes, and snippets.

@kikito
Created May 7, 2011 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikito/960588 to your computer and use it in GitHub Desktop.
Save kikito/960588 to your computer and use it in GitHub Desktop.
#coderetreat #valladolid iteration 7
context('ecomba', function()
context('adam', function()
adam = 1
test('God created Adam', function()
assert_not_nil(adam)
end)
test('dies when alone in paradise', function()
adam = { is_killed_by_god = true }
assert_true(adam.is_killed_by_god)
end)
test('survives if has at least 2 neighbours', function()
adam = { ribs = {1,2,3,4,5,6,7,8} }
eve = table.remove(adam.ribs, 8)
assert_equal(#adam.ribs, 7)
god = { angels = {1,2,3,4,5,6,7,8,9} }
diablo = table.remove(god.angels, 6)
assert_equal(#god.angels, 8)
snake = diablo
adam.neighbours = { eve, diablo }
assert_true(#adam.neighbours >= 2)
adam.is_killed_by_god = not (#adam.neighbours >= 2)
assert_false(adam.is_killed_by_god)
end)
test('we are not using David Hasselhoff as a neighbour', function()
adam = { ribs = {1,2,3,4,5,6,7,8} }
eve = table.remove(adam.ribs, 8)
assert_equal(#adam.ribs, 7)
god = { angels = {1,2,3,4,5,6,7,8,9} }
diablo = table.remove(god.angels, 6)
assert_equal(#god.angels, 8)
snake = diablo
adam.neighbours = { eve, diablo, 'foo' }
assert_true(#adam.neighbours >= 2)
adam.is_killed_by_god = not (#adam.neighbours >= 3)
assert_false(adam.is_killed_by_god)
end)
test('David Hasselhoff is a neighbour so Adam dies', function()
adam = { ribs = {1,2,3,4,5,6,7,8} }
eve = table.remove(adam.ribs, 8)
assert_equal(#adam.ribs, 7)
god = { angels = {1,2,3,4,5,6,7,8,9} }
diablo = table.remove(god.angels, 6)
assert_equal(#god.angels, 8)
snake = diablo
adam.neighbours = { eve, diablo, 'foo', "Hoff" }
assert_true(#adam.neighbours >= 2)
adam.is_killed_by_the_hoff = not (#adam.neighbours >= 3)
assert_false(adam.is_killed_by_the_hoff)
end)
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment