Skip to content

Instantly share code, notes, and snippets.

@dabit
Created March 21, 2014 03:11
Show Gist options
  • Save dabit/9678756 to your computer and use it in GitHub Desktop.
Save dabit/9678756 to your computer and use it in GitHub Desktop.
Hermosillo.rb
#
# Vayan a MagmaConf http://www.magmaconf.com
#
require 'minitest/autorun'
require 'minitest/pride'
class Animal
attr_accessor :clase
def initialize(clase)
self.clase = clase
end
def <=>(b)
valor = { "Vaca" => 0, "Dinosaurio" => 1, "Perro" => 2 }
valor[self.clase] <=> valor[b.clase]
end
end
class TestSort < Minitest::Test
def setup
@perro = Animal.new "Perro"
@dinosaurio = Animal.new "Dinosaurio"
@vaca = Animal.new "Vaca"
@animales = [@perro, @dinosaurio, @vaca]
end
def test_sort
assert @animales.sort[0] == @vaca
assert @animales.sort[1] == @dinosaurio
assert @animales.sort[2] == @perro
end
end
#
# Vayan a MagmaConf http://www.magmaconf.com
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment