diff --git a/library/digest/sha512/length_spec.rb b/library/digest/sha512/length_spec.rb index e9fde90577..47fe2b5e92 100644 --- a/library/digest/sha512/length_spec.rb +++ b/library/digest/sha512/length_spec.rb @@ -1,7 +1,6 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' require_relative 'shared/length' describe "Digest::SHA512#length" do - it_behaves_like :sha512_length, :length + it_behaves_like :sha512_length, :length, Digest::SHA512.new end diff --git a/library/digest/sha512/shared/length.rb b/library/digest/sha512/shared/length.rb index c0609d5386..263f1df5dd 100644 --- a/library/digest/sha512/shared/length.rb +++ b/library/digest/sha512/shared/length.rb @@ -1,8 +1,9 @@ +require_relative 'constants' + describe :sha512_length, shared: true do it "returns the length of the digest" do - cur_digest = Digest::SHA512.new - cur_digest.send(@method).should == SHA512Constants::BlankDigest.size - cur_digest << SHA512Constants::Contents - cur_digest.send(@method).should == SHA512Constants::Digest.size + @object.send(@method).should == SHA512Constants::BlankDigest.size + @object << SHA512Constants::Contents + @object.send(@method).should == SHA512Constants::Digest.size end end diff --git a/library/digest/sha512/size_spec.rb b/library/digest/sha512/size_spec.rb index 6d0acdabdb..171bdf5444 100644 --- a/library/digest/sha512/size_spec.rb +++ b/library/digest/sha512/size_spec.rb @@ -1,7 +1,6 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' require_relative 'shared/length' describe "Digest::SHA512#size" do - it_behaves_like :sha512_length, :size + it_behaves_like :sha512_length, :size, Digest::SHA512.new end diff --git a/library/openssl/digest/digest_length_spec.rb b/library/openssl/digest/digest_length_spec.rb index 37d1cba9a7..155f0d702a 100644 --- a/library/openssl/digest/digest_length_spec.rb +++ b/library/openssl/digest/digest_length_spec.rb @@ -2,7 +2,7 @@ require_relative '../../../library/digest/sha1/shared/constants' require_relative '../../../library/digest/sha256/shared/constants' require_relative '../../../library/digest/sha384/shared/constants' -require_relative '../../../library/digest/sha512/shared/constants' +require_relative '../../digest/sha512/shared/length' require 'openssl' describe "OpenSSL::Digest#digest_length" do @@ -19,9 +19,7 @@ OpenSSL::Digest.new('sha384').digest_length.should == SHA384Constants::DigestLength end - it "returns a SHA512 digest length" do - OpenSSL::Digest.new('sha512').digest_length.should == SHA512Constants::DigestLength - end + it_behaves_like :sha512_length, :digest_length, OpenSSL::Digest.new('sha512') end context "when the digest object is created via a subclass" do @@ -37,8 +35,6 @@ OpenSSL::Digest::SHA384.new.digest_length.should == SHA384Constants::DigestLength end - it "returns a SHA512 digest length" do - OpenSSL::Digest::SHA512.new.digest_length.should == SHA512Constants::DigestLength - end + it_behaves_like :sha512_length, :digest_length, OpenSSL::Digest::SHA512.new end end