aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test
diff options
context:
space:
mode:
authorilovezfs2018-01-21 08:29:38 -0800
committerilovezfs2018-01-22 01:10:14 -0800
commit7c07ec5fc1b0c730d21787b879776e1c1d77cf04 (patch)
treea79031dc475db0ecb7cd03f6739de92d2c362957 /Library/Homebrew/test
parent97f0ef4c49d0f2f2a62a82e7ca21945d7cbe2c7c (diff)
downloadbrew-7c07ec5fc1b0c730d21787b879776e1c1d77cf04.tar.bz2
resource: allow patches to be applied
Diffstat (limited to 'Library/Homebrew/test')
-rw-r--r--Library/Homebrew/test/patch_spec.rb2
-rw-r--r--Library/Homebrew/test/patching_spec.rb27
-rw-r--r--Library/Homebrew/test/resource_spec.rb25
3 files changed, 53 insertions, 1 deletions
diff --git a/Library/Homebrew/test/patch_spec.rb b/Library/Homebrew/test/patch_spec.rb
index 22c103662..56f8f7ea8 100644
--- a/Library/Homebrew/test/patch_spec.rb
+++ b/Library/Homebrew/test/patch_spec.rb
@@ -48,7 +48,7 @@ describe Patch do
subject { described_class.create(:p2, nil) }
context "empty patch" do
- its(:resource) { is_expected.to be_kind_of Resource::Patch }
+ its(:resource) { is_expected.to be_kind_of Resource::PatchResource }
its(:patch_files) { is_expected.to eq(subject.resource.patch_files) }
its(:patch_files) { is_expected.to eq([]) }
end
diff --git a/Library/Homebrew/test/patching_spec.rb b/Library/Homebrew/test/patching_spec.rb
index 502f6204c..05aea1c70 100644
--- a/Library/Homebrew/test/patching_spec.rb
+++ b/Library/Homebrew/test/patching_spec.rb
@@ -30,6 +30,17 @@ describe "patching" do
end
end
+ matcher :have_its_resource_patched do
+ match do |formula|
+ formula.brew do
+ formula.resources.first.stage Pathname.pwd/"resource_dir"
+ s = File.read("resource_dir/libexec/NOOP")
+ expect(s).not_to include("NOOP"), "libexec/NOOP was not patched as expected"
+ expect(s).to include("ABCD"), "libexec/NOOP was not patched as expected"
+ end
+ end
+ end
+
matcher :be_sequentially_patched do
match do |formula|
formula.brew do
@@ -73,6 +84,22 @@ describe "patching" do
).to be_patched
end
+ specify "single_patch_dsl_for_resource" do
+ expect(
+ formula do
+ resource "some_resource" do
+ url TESTBALL_URL
+ sha256 TESTBALL_SHA256
+
+ patch do
+ url PATCH_URL_A
+ sha256 PATCH_A_SHA256
+ end
+ end
+ end,
+ ).to have_its_resource_patched
+ end
+
specify "single_patch_dsl_with_apply" do
expect(
formula do
diff --git a/Library/Homebrew/test/resource_spec.rb b/Library/Homebrew/test/resource_spec.rb
index 7eef3268d..50e174ed4 100644
--- a/Library/Homebrew/test/resource_spec.rb
+++ b/Library/Homebrew/test/resource_spec.rb
@@ -119,6 +119,31 @@ describe Resource do
end
end
+ describe "#owner" do
+ it "sets the owner" do
+ owner = Object.new
+ subject.owner = owner
+ expect(subject.owner).to eq(owner)
+ end
+
+ it "sets its owner to be the patches' owner" do
+ subject.patch(:p1) { url "file:///my.patch" }
+ owner = Object.new
+ subject.owner = owner
+ subject.patches.each do |p|
+ expect(p.resource.owner).to eq(owner)
+ end
+ end
+ end
+
+ describe "#patch" do
+ it "adds a patch" do
+ subject.patch(:p1, :DATA)
+ expect(subject.patches.count).to eq(1)
+ expect(subject.patches.first.strip).to eq(:p1)
+ end
+ end
+
specify "#verify_download_integrity_missing" do
fn = Pathname.new("test")