aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/test_patch.rb52
-rw-r--r--Library/Homebrew/test/test_software_spec.rb6
2 files changed, 58 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_patch.rb b/Library/Homebrew/test/test_patch.rb
new file mode 100644
index 000000000..1cc1ac7af
--- /dev/null
+++ b/Library/Homebrew/test/test_patch.rb
@@ -0,0 +1,52 @@
+require 'testing_env'
+require 'patch'
+
+class PatchTests < Test::Unit::TestCase
+ def test_create_simple
+ patch = Patch.create(:p2)
+ assert_kind_of ExternalPatch, patch
+ assert patch.external?
+ assert_equal :p2, patch.strip
+ end
+
+ def test_create_io
+ patch = Patch.create(:p0, StringIO.new("foo"))
+ assert_kind_of IOPatch, patch
+ assert !patch.external?
+ assert_equal :p0, patch.strip
+ end
+
+ def test_create_io_without_strip
+ patch = Patch.create(StringIO.new("foo"))
+ assert_kind_of IOPatch, patch
+ assert_equal :p1, patch.strip
+ end
+
+ def test_create_string
+ patch = Patch.create(:p0, "foo")
+ assert_kind_of IOPatch, patch
+ assert_equal :p0, patch.strip
+ end
+
+ def test_create_string_without_strip
+ patch = Patch.create("foo")
+ assert_kind_of IOPatch, patch
+ assert_equal :p1, patch.strip
+ end
+
+ def test_create_DATA
+ patch = Patch.create(:p0, :DATA)
+ assert_kind_of IOPatch, patch
+ assert_equal :p0, patch.strip
+ end
+
+ def test_create_DATA_without_strip
+ patch = Patch.create(:DATA)
+ assert_kind_of IOPatch, patch
+ assert_equal :p1, patch.strip
+ end
+
+ def test_raises_for_unknown_values
+ assert_raises(ArgumentError) { Patch.create(Object.new) }
+ end
+end
diff --git a/Library/Homebrew/test/test_software_spec.rb b/Library/Homebrew/test/test_software_spec.rb
index c35294320..7c9fb8720 100644
--- a/Library/Homebrew/test/test_software_spec.rb
+++ b/Library/Homebrew/test/test_software_spec.rb
@@ -80,6 +80,12 @@ class SoftwareSpecTests < Test::Unit::TestCase
@spec.depends_on('foo' => :optional)
assert_equal 'blah', @spec.build.first.description
end
+
+ def test_patch
+ @spec.patch :p1, :DATA
+ assert_equal 1, @spec.patches.length
+ assert_equal :p1, @spec.patches.first.strip
+ end
end
class HeadSoftwareSpecTests < Test::Unit::TestCase