summaryrefslogtreecommitdiff
path: root/spec/bundler/bundler/gem_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/bundler/bundler/gem_helper_spec.rb')
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index 2c43719aa1..5cd79de620 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -66,6 +66,10 @@ RSpec.describe Bundler::GemHelper do
mock_confirm_message message
end
+ def sha512_hexdigest(path)
+ Digest::SHA512.file(path).hexdigest
+ end
+
subject! { Bundler::GemHelper.new(app_path) }
let(:app_version) { "0.1.0" }
let(:app_gem_dir) { app_path.join("pkg") }
@@ -169,12 +173,21 @@ RSpec.describe Bundler::GemHelper do
end
describe "#build_checksum" do
+ it "calculates SHA512 of the content" do
+ FileUtils.mkdir_p(app_gem_dir)
+ File.write(app_gem_path, "")
+ mock_checksum_message app_name, app_version
+ subject.build_checksum(app_gem_path)
+ expect(File.read(app_sha_path).chomp).to eql(Digest::SHA512.hexdigest(""))
+ end
+
context "when build was successful" do
it "creates .sha512 file" do
mock_build_message app_name, app_version
mock_checksum_message app_name, app_version
subject.build_checksum
expect(app_sha_path).to exist
+ expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
end
end
context "when building in the current working directory" do
@@ -185,6 +198,7 @@ RSpec.describe Bundler::GemHelper do
Bundler::GemHelper.new.build_checksum
end
expect(app_sha_path).to exist
+ expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
end
end
context "when building in a location relative to the current working directory" do
@@ -195,6 +209,7 @@ RSpec.describe Bundler::GemHelper do
Bundler::GemHelper.new(File.basename(app_path)).build_checksum
end
expect(app_sha_path).to exist
+ expect(File.read(app_sha_path).chomp).to eql(sha512_hexdigest(app_gem_path))
end
end
end