Fix Formula#<=> on trunk Ruby

Arguably this method shouldn't exist and sort_by(&:name) used instead.
This commit is contained in:
Jack Nagel 2014-07-03 14:54:14 -05:00
parent 618b894c3e
commit b78308d2d5
2 changed files with 9 additions and 2 deletions

View File

@ -301,9 +301,12 @@ class Formula
def hash
name.hash
end
def <=> b
name <=> b.name
def <=>(other)
return unless Formula === other
name <=> other.name
end
def to_s
name
end

View File

@ -139,6 +139,10 @@ class FormulaTests < Homebrew::TestCase
refute_equal TestBall.new, Object.new
end
def test_sort_operator
assert_nil TestBall.new <=> Object.new
end
def test_class_naming
assert_equal 'ShellFm', Formulary.class_s('shell.fm')
assert_equal 'Fooxx', Formulary.class_s('foo++')