From eadb0f60a847feeb5c5001f2bebcb0b030631e10 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 10 Apr 2013 12:02:35 -0500 Subject: [PATCH] Move formula equality tests out of test_bucket --- Library/Homebrew/test/test_bucket.rb | 12 ------------ Library/Homebrew/test/test_formula.rb | 20 ++++++++++++++++++++ Library/Homebrew/test/testball.rb | 4 ++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Library/Homebrew/test/test_bucket.rb b/Library/Homebrew/test/test_bucket.rb index efbc0cdbbf..96d2177a9a 100644 --- a/Library/Homebrew/test/test_bucket.rb +++ b/Library/Homebrew/test/test_bucket.rb @@ -152,16 +152,4 @@ class BeerTasting < Test::Unit::TestCase assert_equal 'foo-0.1', foo1.stem assert_version_equal '0.1', foo1.version end - - def test_formula_equality - f = Class.new(Formula) do - url 'http://example.com/test-0.1.tgz' - end.new('test') - g = Struct.new(:name).new('test') - - assert f == f - assert f == g - assert f.eql? f - assert !f.eql?(g) - end end diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index bdeb398d8d..44d7b9bec4 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -30,6 +30,26 @@ class FormulaTests < Test::Unit::TestCase assert f.installed? end + def test_equality + x = TestBall.new + y = TestBall.new + assert x == y + assert y == x + assert x.eql?(y) + assert y.eql?(x) + assert x.hash == y.hash + end + + def test_inequality + x = TestBall.new("foo") + y = TestBall.new("bar") + assert x != y + assert y != x + assert x.hash != y.hash + assert !x.eql?(y) + assert !y.eql?(x) + end + def test_class_naming assert_equal 'ShellFm', Formula.class_s('shell.fm') assert_equal 'Fooxx', Formula.class_s('foo++') diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index b18fe3e68d..5f8bc08c2e 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -1,14 +1,14 @@ require 'formula' class TestBall < Formula - def initialize(*) + def initialize(name="test_ball") @homepage = 'http://example.com/' self.class.instance_eval do @stable ||= SoftwareSpec.new @stable.url "file:///#{TEST_FOLDER}/tarballs/testball-0.1.tbz" @stable.sha1 "482e737739d946b7c8cbaf127d9ee9c148b999f5" end - super "testball" + super end def install prefix.install "bin"