diff options
Diffstat (limited to 'spec/ruby/library/digest')
39 files changed, 113 insertions, 140 deletions
diff --git a/spec/ruby/library/digest/bubblebabble_spec.rb b/spec/ruby/library/digest/bubblebabble_spec.rb index bbc11ceec5..44a9bf0e26 100644 --- a/spec/ruby/library/digest/bubblebabble_spec.rb +++ b/spec/ruby/library/digest/bubblebabble_spec.rb @@ -3,7 +3,7 @@ require 'digest/bubblebabble' describe "Digest.bubblebabble" do it "returns a String" do - Digest.bubblebabble('').should be_an_instance_of(String) + Digest.bubblebabble('').should.instance_of?(String) end it "returns a String in the Bubble Babble Binary Data Encoding format" do @@ -20,10 +20,10 @@ describe "Digest.bubblebabble" do end it "raises a TypeError when passed nil" do - -> { Digest.bubblebabble(nil) }.should raise_error(TypeError) + -> { Digest.bubblebabble(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { Digest.bubblebabble(9001) }.should raise_error(TypeError) + -> { Digest.bubblebabble(9001) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/hexencode_spec.rb b/spec/ruby/library/digest/hexencode_spec.rb index 4b6db6eaff..3359303d15 100644 --- a/spec/ruby/library/digest/hexencode_spec.rb +++ b/spec/ruby/library/digest/hexencode_spec.rb @@ -22,10 +22,10 @@ describe "Digest.hexencode" do end it "raises a TypeError when passed nil" do - -> { Digest.hexencode(nil) }.should raise_error(TypeError) + -> { Digest.hexencode(nil) }.should.raise(TypeError) end it "raises a TypeError when passed an Integer" do - -> { Digest.hexencode(9001) }.should raise_error(TypeError) + -> { Digest.hexencode(9001) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/instance/append_spec.rb b/spec/ruby/library/digest/instance/append_spec.rb index 2499579298..7f4ce3d121 100644 --- a/spec/ruby/library/digest/instance/append_spec.rb +++ b/spec/ruby/library/digest/instance/append_spec.rb @@ -1,7 +1,11 @@ require_relative '../../../spec_helper' require 'digest' -require_relative 'shared/update' describe "Digest::Instance#<<" do - it_behaves_like :digest_instance_update, :<< + it "raises a RuntimeError if called" do + c = Class.new do + include Digest::Instance + end + -> { c.new << "test" }.should.raise(RuntimeError) + end end diff --git a/spec/ruby/library/digest/instance/shared/update.rb b/spec/ruby/library/digest/instance/shared/update.rb deleted file mode 100644 index 17779e54a4..0000000000 --- a/spec/ruby/library/digest/instance/shared/update.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe :digest_instance_update, shared: true do - it "raises a RuntimeError if called" do - c = Class.new do - include Digest::Instance - end - -> { c.new.send(@method, "test") }.should raise_error(RuntimeError) - end -end diff --git a/spec/ruby/library/digest/instance/update_spec.rb b/spec/ruby/library/digest/instance/update_spec.rb index 3bb4dd7f1b..d15b976213 100644 --- a/spec/ruby/library/digest/instance/update_spec.rb +++ b/spec/ruby/library/digest/instance/update_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' require 'digest' -require_relative 'shared/update' describe "Digest::Instance#update" do - it_behaves_like :digest_instance_update, :update + it "is an alias of Digest::Instance#<<" do + Digest::Instance.instance_method(:update).should == Digest::Instance.instance_method(:<<) + end end diff --git a/spec/ruby/library/digest/md5/append_spec.rb b/spec/ruby/library/digest/md5/append_spec.rb index a7f841c883..6f42e4f286 100644 --- a/spec/ruby/library/digest/md5/append_spec.rb +++ b/spec/ruby/library/digest/md5/append_spec.rb @@ -1,7 +1,10 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/update' describe "Digest::MD5#<<" do - it_behaves_like :md5_update, :<< + it "can update" do + cur_digest = Digest::MD5.new + cur_digest << MD5Constants::Contents + cur_digest.digest.should == MD5Constants::Digest + end end diff --git a/spec/ruby/library/digest/md5/file_spec.rb b/spec/ruby/library/digest/md5/file_spec.rb index 0c8d12cbc9..9a78a8c055 100644 --- a/spec/ruby/library/digest/md5/file_spec.rb +++ b/spec/ruby/library/digest/md5/file_spec.rb @@ -15,7 +15,7 @@ describe "Digest::MD5.file" do end it "returns a Digest::MD5 object" do - Digest::MD5.file(@file).should be_kind_of(Digest::MD5) + Digest::MD5.file(@file).should.is_a?(Digest::MD5) end it "returns a Digest::MD5 object with the correct digest" do @@ -26,7 +26,7 @@ describe "Digest::MD5.file" do obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::MD5.file(obj) - result.should be_kind_of(Digest::MD5) + result.should.is_a?(Digest::MD5) result.digest.should == MD5Constants::Digest end end @@ -34,10 +34,10 @@ describe "Digest::MD5.file" do it_behaves_like :file_read_directory, :file, Digest::MD5 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::MD5.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::MD5.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::MD5.file(nil) }.should raise_error(TypeError) + -> { Digest::MD5.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/md5/length_spec.rb b/spec/ruby/library/digest/md5/length_spec.rb index b05b2a20fd..18bda51129 100644 --- a/spec/ruby/library/digest/md5/length_spec.rb +++ b/spec/ruby/library/digest/md5/length_spec.rb @@ -1,7 +1,11 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::MD5#length" do - it_behaves_like :md5_length, :length + it "returns the length of the digest" do + cur_digest = Digest::MD5.new + cur_digest.length.should == MD5Constants::BlankDigest.size + cur_digest << MD5Constants::Contents + cur_digest.length.should == MD5Constants::Digest.size + end end diff --git a/spec/ruby/library/digest/md5/shared/constants.rb b/spec/ruby/library/digest/md5/shared/constants.rb index e807b96f9f..664dd18e9c 100644 --- a/spec/ruby/library/digest/md5/shared/constants.rb +++ b/spec/ruby/library/digest/md5/shared/constants.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require 'digest/md5' module MD5Constants diff --git a/spec/ruby/library/digest/md5/shared/length.rb b/spec/ruby/library/digest/md5/shared/length.rb deleted file mode 100644 index c5b2b97b58..0000000000 --- a/spec/ruby/library/digest/md5/shared/length.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe :md5_length, shared: true do - it "returns the length of the digest" do - cur_digest = Digest::MD5.new - cur_digest.send(@method).should == MD5Constants::BlankDigest.size - cur_digest << MD5Constants::Contents - cur_digest.send(@method).should == MD5Constants::Digest.size - end -end diff --git a/spec/ruby/library/digest/md5/shared/update.rb b/spec/ruby/library/digest/md5/shared/update.rb deleted file mode 100644 index be8622aed5..0000000000 --- a/spec/ruby/library/digest/md5/shared/update.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :md5_update, shared: true do - it "can update" do - cur_digest = Digest::MD5.new - cur_digest.send @method, MD5Constants::Contents - cur_digest.digest.should == MD5Constants::Digest - end -end diff --git a/spec/ruby/library/digest/md5/size_spec.rb b/spec/ruby/library/digest/md5/size_spec.rb index 22e3272d36..54709234de 100644 --- a/spec/ruby/library/digest/md5/size_spec.rb +++ b/spec/ruby/library/digest/md5/size_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::MD5#size" do - it_behaves_like :md5_length, :size + it "is an alias of Digest::MD5#length" do + Digest::MD5.instance_method(:size).should == Digest::MD5.instance_method(:length) + end end diff --git a/spec/ruby/library/digest/md5/update_spec.rb b/spec/ruby/library/digest/md5/update_spec.rb index 4773db308c..830ccfead6 100644 --- a/spec/ruby/library/digest/md5/update_spec.rb +++ b/spec/ruby/library/digest/md5/update_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/update' +require 'digest' describe "Digest::MD5#update" do - it_behaves_like :md5_update, :update + it "is an alias of Digest::MD5#<<" do + Digest::MD5.instance_method(:update).should == Digest::MD5.instance_method(:<<) + end end diff --git a/spec/ruby/library/digest/sha1/file_spec.rb b/spec/ruby/library/digest/sha1/file_spec.rb index 9c15f5b02f..d36e560e21 100644 --- a/spec/ruby/library/digest/sha1/file_spec.rb +++ b/spec/ruby/library/digest/sha1/file_spec.rb @@ -15,7 +15,7 @@ describe "Digest::SHA1.file" do end it "returns a Digest::SHA1 object" do - Digest::SHA1.file(@file).should be_kind_of(Digest::SHA1) + Digest::SHA1.file(@file).should.is_a?(Digest::SHA1) end it "returns a Digest::SHA1 object with the correct digest" do @@ -26,7 +26,7 @@ describe "Digest::SHA1.file" do obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA1.file(obj) - result.should be_kind_of(Digest::SHA1) + result.should.is_a?(Digest::SHA1) result.digest.should == SHA1Constants::Digest end end @@ -34,10 +34,10 @@ describe "Digest::SHA1.file" do it_behaves_like :file_read_directory, :file, Digest::SHA1 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA1.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA1.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA1.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha1/shared/constants.rb b/spec/ruby/library/digest/sha1/shared/constants.rb index 169438747f..d77c05a968 100644 --- a/spec/ruby/library/digest/sha1/shared/constants.rb +++ b/spec/ruby/library/digest/sha1/shared/constants.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require 'digest/sha1' diff --git a/spec/ruby/library/digest/sha256/append_spec.rb b/spec/ruby/library/digest/sha256/append_spec.rb index 9ca3496afc..f18b06c2a1 100644 --- a/spec/ruby/library/digest/sha256/append_spec.rb +++ b/spec/ruby/library/digest/sha256/append_spec.rb @@ -1,7 +1,10 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/update' describe "Digest::SHA256#<<" do - it_behaves_like :sha256_update, :<< + it "can update" do + cur_digest = Digest::SHA256.new + cur_digest << SHA256Constants::Contents + cur_digest.digest.should == SHA256Constants::Digest + end end diff --git a/spec/ruby/library/digest/sha256/file_spec.rb b/spec/ruby/library/digest/sha256/file_spec.rb index 8cbc5a2755..d67a9ebcd6 100644 --- a/spec/ruby/library/digest/sha256/file_spec.rb +++ b/spec/ruby/library/digest/sha256/file_spec.rb @@ -15,7 +15,7 @@ describe "Digest::SHA256.file" do end it "returns a Digest::SHA256 object" do - Digest::SHA256.file(@file).should be_kind_of(Digest::SHA256) + Digest::SHA256.file(@file).should.is_a?(Digest::SHA256) end it "returns a Digest::SHA256 object with the correct digest" do @@ -30,7 +30,7 @@ describe "Digest::SHA256.file" do obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA256.file(obj) - result.should be_kind_of(Digest::SHA256) + result.should.is_a?(Digest::SHA256) result.digest.should == SHA256Constants::Digest end end @@ -38,10 +38,10 @@ describe "Digest::SHA256.file" do it_behaves_like :file_read_directory, :file, Digest::SHA256 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA256.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA256.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA256.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha256/length_spec.rb b/spec/ruby/library/digest/sha256/length_spec.rb index 181ac564ad..fc3db6548e 100644 --- a/spec/ruby/library/digest/sha256/length_spec.rb +++ b/spec/ruby/library/digest/sha256/length_spec.rb @@ -1,7 +1,11 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::SHA256#length" do - it_behaves_like :sha256_length, :length + it "returns the length of the digest" do + cur_digest = Digest::SHA256.new + cur_digest.length.should == SHA256Constants::BlankDigest.size + cur_digest << SHA256Constants::Contents + cur_digest.length.should == SHA256Constants::Digest.size + end end diff --git a/spec/ruby/library/digest/sha256/shared/constants.rb b/spec/ruby/library/digest/sha256/shared/constants.rb index 351679f344..afe8f11426 100644 --- a/spec/ruby/library/digest/sha256/shared/constants.rb +++ b/spec/ruby/library/digest/sha256/shared/constants.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require 'digest/sha2' diff --git a/spec/ruby/library/digest/sha256/shared/length.rb b/spec/ruby/library/digest/sha256/shared/length.rb deleted file mode 100644 index 996673a5bd..0000000000 --- a/spec/ruby/library/digest/sha256/shared/length.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe :sha256_length, shared: true do - it "returns the length of the digest" do - cur_digest = Digest::SHA256.new - cur_digest.send(@method).should == SHA256Constants::BlankDigest.size - cur_digest << SHA256Constants::Contents - cur_digest.send(@method).should == SHA256Constants::Digest.size - end -end diff --git a/spec/ruby/library/digest/sha256/shared/update.rb b/spec/ruby/library/digest/sha256/shared/update.rb deleted file mode 100644 index 0edc07935b..0000000000 --- a/spec/ruby/library/digest/sha256/shared/update.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :sha256_update, shared: true do - it "can update" do - cur_digest = Digest::SHA256.new - cur_digest.send @method, SHA256Constants::Contents - cur_digest.digest.should == SHA256Constants::Digest - end -end diff --git a/spec/ruby/library/digest/sha256/size_spec.rb b/spec/ruby/library/digest/sha256/size_spec.rb index 1028263342..6102e1c8aa 100644 --- a/spec/ruby/library/digest/sha256/size_spec.rb +++ b/spec/ruby/library/digest/sha256/size_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::SHA256#size" do - it_behaves_like :sha256_length, :size + it "is an alias of Digest::SHA256#length" do + Digest::SHA256.instance_method(:size).should == Digest::SHA256.instance_method(:length) + end end diff --git a/spec/ruby/library/digest/sha256/update_spec.rb b/spec/ruby/library/digest/sha256/update_spec.rb index 92316eb752..d6724936f1 100644 --- a/spec/ruby/library/digest/sha256/update_spec.rb +++ b/spec/ruby/library/digest/sha256/update_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/update' +require 'digest' describe "Digest::SHA256#update" do - it_behaves_like :sha256_update, :update + it "is an alias of Digest::SHA256#<<" do + Digest::SHA256.instance_method(:update).should == Digest::SHA256.instance_method(:<<) + end end diff --git a/spec/ruby/library/digest/sha384/append_spec.rb b/spec/ruby/library/digest/sha384/append_spec.rb index 2bc0c5b90b..b9a862f1c2 100644 --- a/spec/ruby/library/digest/sha384/append_spec.rb +++ b/spec/ruby/library/digest/sha384/append_spec.rb @@ -1,7 +1,10 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/update' describe "Digest::SHA384#<<" do - it_behaves_like :sha384_update, :<< + it "can update" do + cur_digest = Digest::SHA384.new + cur_digest << SHA384Constants::Contents + cur_digest.digest.should == SHA384Constants::Digest + end end diff --git a/spec/ruby/library/digest/sha384/file_spec.rb b/spec/ruby/library/digest/sha384/file_spec.rb index 8556f10175..3726ad4423 100644 --- a/spec/ruby/library/digest/sha384/file_spec.rb +++ b/spec/ruby/library/digest/sha384/file_spec.rb @@ -15,7 +15,7 @@ describe "Digest::SHA384.file" do end it "returns a Digest::SHA384 object" do - Digest::SHA384.file(@file).should be_kind_of(Digest::SHA384) + Digest::SHA384.file(@file).should.is_a?(Digest::SHA384) end it "returns a Digest::SHA384 object with the correct digest" do @@ -26,7 +26,7 @@ describe "Digest::SHA384.file" do obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA384.file(obj) - result.should be_kind_of(Digest::SHA384) + result.should.is_a?(Digest::SHA384) result.digest.should == SHA384Constants::Digest end end @@ -34,10 +34,10 @@ describe "Digest::SHA384.file" do it_behaves_like :file_read_directory, :file, Digest::SHA384 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA384.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA384.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA384.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha384/length_spec.rb b/spec/ruby/library/digest/sha384/length_spec.rb index 33fed492ef..e5cd6131fd 100644 --- a/spec/ruby/library/digest/sha384/length_spec.rb +++ b/spec/ruby/library/digest/sha384/length_spec.rb @@ -1,7 +1,11 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::SHA384#length" do - it_behaves_like :sha384_length, :length + it "returns the length of the digest" do + cur_digest = Digest::SHA384.new + cur_digest.length.should == SHA384Constants::BlankDigest.size + cur_digest << SHA384Constants::Contents + cur_digest.length.should == SHA384Constants::Digest.size + end end diff --git a/spec/ruby/library/digest/sha384/shared/constants.rb b/spec/ruby/library/digest/sha384/shared/constants.rb index 2050f03f2b..a78d571d26 100644 --- a/spec/ruby/library/digest/sha384/shared/constants.rb +++ b/spec/ruby/library/digest/sha384/shared/constants.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require 'digest/sha2' diff --git a/spec/ruby/library/digest/sha384/shared/length.rb b/spec/ruby/library/digest/sha384/shared/length.rb deleted file mode 100644 index 0c88288bcf..0000000000 --- a/spec/ruby/library/digest/sha384/shared/length.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe :sha384_length, shared: true do - it "returns the length of the digest" do - cur_digest = Digest::SHA384.new - cur_digest.send(@method).should == SHA384Constants::BlankDigest.size - cur_digest << SHA384Constants::Contents - cur_digest.send(@method).should == SHA384Constants::Digest.size - end -end diff --git a/spec/ruby/library/digest/sha384/shared/update.rb b/spec/ruby/library/digest/sha384/shared/update.rb deleted file mode 100644 index 1c6e31cf6a..0000000000 --- a/spec/ruby/library/digest/sha384/shared/update.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :sha384_update, shared: true do - it "can update" do - cur_digest = Digest::SHA384.new - cur_digest.send @method, SHA384Constants::Contents - cur_digest.digest.should == SHA384Constants::Digest - end -end diff --git a/spec/ruby/library/digest/sha384/size_spec.rb b/spec/ruby/library/digest/sha384/size_spec.rb index 4c3b14f7a0..40c291c623 100644 --- a/spec/ruby/library/digest/sha384/size_spec.rb +++ b/spec/ruby/library/digest/sha384/size_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/length' +require 'digest' describe "Digest::SHA384#size" do - it_behaves_like :sha384_length, :size + it "is an alias of Digest::SHA384#length" do + Digest::SHA384.instance_method(:size).should == Digest::SHA384.instance_method(:length) + end end diff --git a/spec/ruby/library/digest/sha384/update_spec.rb b/spec/ruby/library/digest/sha384/update_spec.rb index a1d0dd6068..561dcad3ec 100644 --- a/spec/ruby/library/digest/sha384/update_spec.rb +++ b/spec/ruby/library/digest/sha384/update_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/update' +require 'digest' describe "Digest::SHA384#update" do - it_behaves_like :sha384_update, :update + it "is an alias of Digest::SHA384#<<" do + Digest::SHA384.instance_method(:update).should == Digest::SHA384.instance_method(:<<) + end end diff --git a/spec/ruby/library/digest/sha512/append_spec.rb b/spec/ruby/library/digest/sha512/append_spec.rb index e5f84b56f4..f297005403 100644 --- a/spec/ruby/library/digest/sha512/append_spec.rb +++ b/spec/ruby/library/digest/sha512/append_spec.rb @@ -1,7 +1,10 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/update' describe "Digest::SHA512#<<" do - it_behaves_like :sha512_update, :<< + it "can update" do + cur_digest = Digest::SHA512.new + cur_digest << SHA512Constants::Contents + cur_digest.digest.should == SHA512Constants::Digest + end end diff --git a/spec/ruby/library/digest/sha512/file_spec.rb b/spec/ruby/library/digest/sha512/file_spec.rb index 781ec781e5..78d6d3d4f3 100644 --- a/spec/ruby/library/digest/sha512/file_spec.rb +++ b/spec/ruby/library/digest/sha512/file_spec.rb @@ -15,7 +15,7 @@ describe "Digest::SHA512.file" do end it "returns a Digest::SHA512 object" do - Digest::SHA512.file(@file).should be_kind_of(Digest::SHA512) + Digest::SHA512.file(@file).should.is_a?(Digest::SHA512) end it "returns a Digest::SHA512 object with the correct digest" do @@ -26,7 +26,7 @@ describe "Digest::SHA512.file" do obj = mock("to_str") obj.should_receive(:to_str).and_return(@file) result = Digest::SHA512.file(obj) - result.should be_kind_of(Digest::SHA512) + result.should.is_a?(Digest::SHA512) result.digest.should == SHA512Constants::Digest end end @@ -34,10 +34,10 @@ describe "Digest::SHA512.file" do it_behaves_like :file_read_directory, :file, Digest::SHA512 it "raises a Errno::ENOENT when passed a path that does not exist" do - -> { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA512.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - -> { Digest::SHA512.file(nil) }.should raise_error(TypeError) + -> { Digest::SHA512.file(nil) }.should.raise(TypeError) end end diff --git a/spec/ruby/library/digest/sha512/length_spec.rb b/spec/ruby/library/digest/sha512/length_spec.rb index e9fde90577..8e909482c5 100644 --- a/spec/ruby/library/digest/sha512/length_spec.rb +++ b/spec/ruby/library/digest/sha512/length_spec.rb @@ -1,7 +1,11 @@ require_relative '../../../spec_helper' require_relative 'shared/constants' -require_relative 'shared/length' describe "Digest::SHA512#length" do - it_behaves_like :sha512_length, :length + it "returns the length of the digest" do + cur_digest = Digest::SHA512.new + cur_digest.length.should == SHA512Constants::BlankDigest.size + cur_digest << SHA512Constants::Contents + cur_digest.length.should == SHA512Constants::Digest.size + end end diff --git a/spec/ruby/library/digest/sha512/shared/constants.rb b/spec/ruby/library/digest/sha512/shared/constants.rb index 2765a1ec16..91787381ee 100644 --- a/spec/ruby/library/digest/sha512/shared/constants.rb +++ b/spec/ruby/library/digest/sha512/shared/constants.rb @@ -1,4 +1,4 @@ -# -*- encoding: binary -*- +# encoding: binary require 'digest/sha2' diff --git a/spec/ruby/library/digest/sha512/shared/length.rb b/spec/ruby/library/digest/sha512/shared/length.rb deleted file mode 100644 index c0609d5386..0000000000 --- a/spec/ruby/library/digest/sha512/shared/length.rb +++ /dev/null @@ -1,8 +0,0 @@ -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 - end -end diff --git a/spec/ruby/library/digest/sha512/shared/update.rb b/spec/ruby/library/digest/sha512/shared/update.rb deleted file mode 100644 index ca74dbf4df..0000000000 --- a/spec/ruby/library/digest/sha512/shared/update.rb +++ /dev/null @@ -1,7 +0,0 @@ -describe :sha512_update, shared: true do - it "can update" do - cur_digest = Digest::SHA512.new - cur_digest.send @method, SHA512Constants::Contents - cur_digest.digest.should == SHA512Constants::Digest - end -end diff --git a/spec/ruby/library/digest/sha512/size_spec.rb b/spec/ruby/library/digest/sha512/size_spec.rb index 6d0acdabdb..498d686802 100644 --- a/spec/ruby/library/digest/sha512/size_spec.rb +++ b/spec/ruby/library/digest/sha512/size_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/length' +require 'digest' describe "Digest::SHA512#size" do - it_behaves_like :sha512_length, :size + it "is an alias of Digest::SHA512#length" do + Digest::SHA512.instance_method(:size).should == Digest::SHA512.instance_method(:length) + end end diff --git a/spec/ruby/library/digest/sha512/update_spec.rb b/spec/ruby/library/digest/sha512/update_spec.rb index 682d3a19bb..33edf216ac 100644 --- a/spec/ruby/library/digest/sha512/update_spec.rb +++ b/spec/ruby/library/digest/sha512/update_spec.rb @@ -1,7 +1,8 @@ require_relative '../../../spec_helper' -require_relative 'shared/constants' -require_relative 'shared/update' +require 'digest' describe "Digest::SHA512#update" do - it_behaves_like :sha512_update, :update + it "is an alias of Digest::SHA512#<<" do + Digest::SHA512.instance_method(:update).should == Digest::SHA512.instance_method(:<<) + end end |
