diff options
Diffstat (limited to 'spec/ruby/library/digest')
75 files changed, 267 insertions, 230 deletions
diff --git a/spec/ruby/library/digest/bubblebabble_spec.rb b/spec/ruby/library/digest/bubblebabble_spec.rb index 49cc77e623..44a9bf0e26 100644 --- a/spec/ruby/library/digest/bubblebabble_spec.rb +++ b/spec/ruby/library/digest/bubblebabble_spec.rb @@ -1,12 +1,12 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' 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 The Bubble Babble Binary Data Encoding format" do + it "returns a String in the Bubble Babble Binary Data Encoding format" do Digest.bubblebabble('').should == 'xexax' Digest.bubblebabble('foo').should == 'xinik-zorox' Digest.bubblebabble('bar').should == 'ximik-cosex' @@ -20,10 +20,10 @@ describe "Digest.bubblebabble" do end it "raises a TypeError when passed nil" do - lambda { Digest.bubblebabble(nil) }.should raise_error(TypeError) + -> { Digest.bubblebabble(nil) }.should.raise(TypeError) end - it "raises a TypeError when passed a Fixnum" do - lambda { Digest.bubblebabble(9001) }.should raise_error(TypeError) + it "raises a TypeError when passed an Integer" do + -> { 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 9e59e69fce..3359303d15 100644 --- a/spec/ruby/library/digest/hexencode_spec.rb +++ b/spec/ruby/library/digest/hexencode_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' require 'digest' describe "Digest.hexencode" do @@ -22,10 +22,10 @@ describe "Digest.hexencode" do end it "raises a TypeError when passed nil" do - lambda { Digest.hexencode(nil) }.should raise_error(TypeError) + -> { Digest.hexencode(nil) }.should.raise(TypeError) end - it "raises a TypeError when passed a Fixnum" do - lambda { Digest.hexencode(9001) }.should raise_error(TypeError) + it "raises a TypeError when passed an Integer" do + -> { 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 new file mode 100644 index 0000000000..2499579298 --- /dev/null +++ b/spec/ruby/library/digest/instance/append_spec.rb @@ -0,0 +1,7 @@ +require_relative '../../../spec_helper' +require 'digest' +require_relative 'shared/update' + +describe "Digest::Instance#<<" do + it_behaves_like :digest_instance_update, :<< +end diff --git a/spec/ruby/library/digest/instance/new_spec.rb b/spec/ruby/library/digest/instance/new_spec.rb new file mode 100644 index 0000000000..3f7939844b --- /dev/null +++ b/spec/ruby/library/digest/instance/new_spec.rb @@ -0,0 +1,19 @@ +require_relative '../../../spec_helper' +require 'digest' +require_relative '../md5/shared/constants' + +describe "Digest::Instance#new" do + it "returns a copy of the digest instance" do + digest = Digest::MD5.new + copy = digest.new + copy.should_not.equal?(digest) + end + + it "calls reset" do + digest = Digest::MD5.new + digest << "test" + digest.hexdigest.should != MD5Constants::BlankHexdigest + copy = digest.new + copy.hexdigest.should == MD5Constants::BlankHexdigest + end +end diff --git a/spec/ruby/library/digest/instance/shared/update.rb b/spec/ruby/library/digest/instance/shared/update.rb new file mode 100644 index 0000000000..e064a90087 --- /dev/null +++ b/spec/ruby/library/digest/instance/shared/update.rb @@ -0,0 +1,8 @@ +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(RuntimeError) + end +end diff --git a/spec/ruby/library/digest/instance/update_spec.rb b/spec/ruby/library/digest/instance/update_spec.rb new file mode 100644 index 0000000000..3bb4dd7f1b --- /dev/null +++ b/spec/ruby/library/digest/instance/update_spec.rb @@ -0,0 +1,7 @@ +require_relative '../../../spec_helper' +require 'digest' +require_relative 'shared/update' + +describe "Digest::Instance#update" do + it_behaves_like :digest_instance_update, :update +end diff --git a/spec/ruby/library/digest/md5/append_spec.rb b/spec/ruby/library/digest/md5/append_spec.rb index ad828c83c1..0abdc074a1 100644 --- a/spec/ruby/library/digest/md5/append_spec.rb +++ b/spec/ruby/library/digest/md5/append_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::MD5#<<" do - it_behaves_like(:md5_update, :<<) + it_behaves_like :md5_update, :<< end diff --git a/spec/ruby/library/digest/md5/block_length_spec.rb b/spec/ruby/library/digest/md5/block_length_spec.rb index acc3108da4..14fb050abd 100644 --- a/spec/ruby/library/digest/md5/block_length_spec.rb +++ b/spec/ruby/library/digest/md5/block_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#block_length" do @@ -9,4 +9,3 @@ describe "Digest::MD5#block_length" do end end - diff --git a/spec/ruby/library/digest/md5/digest_bang_spec.rb b/spec/ruby/library/digest/md5/digest_bang_spec.rb index 88b865dcba..7b884a16d9 100644 --- a/spec/ruby/library/digest/md5/digest_bang_spec.rb +++ b/spec/ruby/library/digest/md5/digest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#digest!" do diff --git a/spec/ruby/library/digest/md5/digest_length_spec.rb b/spec/ruby/library/digest/md5/digest_length_spec.rb index 426e42af76..47e071e329 100644 --- a/spec/ruby/library/digest/md5/digest_length_spec.rb +++ b/spec/ruby/library/digest/md5/digest_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#digest_length" do @@ -9,4 +9,3 @@ describe "Digest::MD5#digest_length" do end end - diff --git a/spec/ruby/library/digest/md5/digest_spec.rb b/spec/ruby/library/digest/md5/digest_spec.rb index 1568c630aa..d9bbc45ee2 100644 --- a/spec/ruby/library/digest/md5/digest_spec.rb +++ b/spec/ruby/library/digest/md5/digest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#digest" do diff --git a/spec/ruby/library/digest/md5/equal_spec.rb b/spec/ruby/library/digest/md5/equal_spec.rb index 0b776f53c0..b0e36564cd 100644 --- a/spec/ruby/library/digest/md5/equal_spec.rb +++ b/spec/ruby/library/digest/md5/equal_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#==" do @@ -35,4 +35,3 @@ describe "Digest::MD5#==" do end end - diff --git a/spec/ruby/library/digest/md5/file_spec.rb b/spec/ruby/library/digest/md5/file_spec.rb index c7f4328546..9a78a8c055 100644 --- a/spec/ruby/library/digest/md5/file_spec.rb +++ b/spec/ruby/library/digest/md5/file_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../../../../core/file/shared/read', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative '../../../core/file/shared/read' describe "Digest::MD5.file" do @@ -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 - lambda { Digest::MD5.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::MD5.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - lambda { 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/hexdigest_bang_spec.rb b/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb index fe67136c97..a953eb3b4c 100644 --- a/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb +++ b/spec/ruby/library/digest/md5/hexdigest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#hexdigest!" do diff --git a/spec/ruby/library/digest/md5/hexdigest_spec.rb b/spec/ruby/library/digest/md5/hexdigest_spec.rb index 9caec29f38..03ead68b82 100644 --- a/spec/ruby/library/digest/md5/hexdigest_spec.rb +++ b/spec/ruby/library/digest/md5/hexdigest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#hexdigest" do diff --git a/spec/ruby/library/digest/md5/inspect_spec.rb b/spec/ruby/library/digest/md5/inspect_spec.rb index e23465337a..decc86fba5 100644 --- a/spec/ruby/library/digest/md5/inspect_spec.rb +++ b/spec/ruby/library/digest/md5/inspect_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#inspect" do @@ -9,4 +9,3 @@ describe "Digest::MD5#inspect" do end end - diff --git a/spec/ruby/library/digest/md5/length_spec.rb b/spec/ruby/library/digest/md5/length_spec.rb index 13eaf2e8d5..b05b2a20fd 100644 --- a/spec/ruby/library/digest/md5/length_spec.rb +++ b/spec/ruby/library/digest/md5/length_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::MD5#length" do it_behaves_like :md5_length, :length end - diff --git a/spec/ruby/library/digest/md5/reset_spec.rb b/spec/ruby/library/digest/md5/reset_spec.rb index d95ecfaf8c..c937844f38 100644 --- a/spec/ruby/library/digest/md5/reset_spec.rb +++ b/spec/ruby/library/digest/md5/reset_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::MD5#reset" do @@ -12,4 +12,3 @@ describe "Digest::MD5#reset" do end end - diff --git a/spec/ruby/library/digest/md5/shared/constants.rb b/spec/ruby/library/digest/md5/shared/constants.rb index fdfae56d63..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 @@ -12,5 +12,6 @@ module MD5Constants Digest = "\2473\267qw\276\364\343\345\320\304\350\313\314\217n" BlankHexdigest = "d41d8cd98f00b204e9800998ecf8427e" Hexdigest = "a733b77177bef4e3e5d0c4e8cbcc8f6e" + Base64digest = "pzO3cXe+9OPl0MToy8yPbg==" end diff --git a/spec/ruby/library/digest/md5/shared/sample.rb b/spec/ruby/library/digest/md5/shared/sample.rb deleted file mode 100644 index 2bb4f658b1..0000000000 --- a/spec/ruby/library/digest/md5/shared/sample.rb +++ /dev/null @@ -1,17 +0,0 @@ -# -*- encoding: binary -*- - -require 'digest/md5' - -module MD5Constants - - Contents = "Ipsum is simply dummy text of the printing and typesetting industry. \nLorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \nIt has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \nIt was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." - - Klass = ::Digest::MD5 - BlockLength = 64 - DigestLength = 16 - BlankDigest = "\324\035\214\331\217\000\262\004\351\200\t\230\354\370B~" - Digest = "\2473\267qw\276\364\343\345\320\304\350\313\314\217n" - BlankHexdigest = "d41d8cd98f00b204e9800998ecf8427e" - Hexdigest = "a733b77177bef4e3e5d0c4e8cbcc8f6e" - -end diff --git a/spec/ruby/library/digest/md5/size_spec.rb b/spec/ruby/library/digest/md5/size_spec.rb index 311286e679..22e3272d36 100644 --- a/spec/ruby/library/digest/md5/size_spec.rb +++ b/spec/ruby/library/digest/md5/size_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::MD5#size" do it_behaves_like :md5_length, :size end - diff --git a/spec/ruby/library/digest/md5/to_s_spec.rb b/spec/ruby/library/digest/md5/to_s_spec.rb index 59c17ec821..78d53d6967 100644 --- a/spec/ruby/library/digest/md5/to_s_spec.rb +++ b/spec/ruby/library/digest/md5/to_s_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../../spec_helper', __FILE__) +require_relative '../../../spec_helper' require 'digest/md5' -require File.expand_path('../shared/constants', __FILE__) +require_relative 'shared/constants' describe "Digest::MD5#to_s" do diff --git a/spec/ruby/library/digest/md5/update_spec.rb b/spec/ruby/library/digest/md5/update_spec.rb index 5a271481f7..4773db308c 100644 --- a/spec/ruby/library/digest/md5/update_spec.rb +++ b/spec/ruby/library/digest/md5/update_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::MD5#update" do it_behaves_like :md5_update, :update diff --git a/spec/ruby/library/digest/sha1/digest_spec.rb b/spec/ruby/library/digest/sha1/digest_spec.rb index abb4034a69..03f805336f 100644 --- a/spec/ruby/library/digest/sha1/digest_spec.rb +++ b/spec/ruby/library/digest/sha1/digest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA1#digest" do diff --git a/spec/ruby/library/digest/sha1/file_spec.rb b/spec/ruby/library/digest/sha1/file_spec.rb index 2c9fd2cb52..d36e560e21 100644 --- a/spec/ruby/library/digest/sha1/file_spec.rb +++ b/spec/ruby/library/digest/sha1/file_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../../../../core/file/shared/read', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative '../../../core/file/shared/read' describe "Digest::SHA1.file" do @@ -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 - lambda { Digest::SHA1.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA1.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - lambda { 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 add86b1dd3..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' @@ -12,6 +12,7 @@ module SHA1Constants BlankDigest = "\3329\243\356^kK\r2U\277\357\225`\030\220\257\330\a\t" Digest = "X!\255b\323\035\352\314a|q\344+\376\317\361V9\324\343" BlankHexdigest = "da39a3ee5e6b4b0d3255bfef95601890afd80709" - Hexdigest = "e907d2ba21c6c74bc0efd76e44d11fb9bbb7a75e" + Hexdigest = "5821ad62d31deacc617c71e42bfecff15639d4e3" + Base64digest = "WCGtYtMd6sxhfHHkK/7P8VY51OM=" end diff --git a/spec/ruby/library/digest/sha2/hexdigest_spec.rb b/spec/ruby/library/digest/sha2/hexdigest_spec.rb new file mode 100644 index 0000000000..79beca5788 --- /dev/null +++ b/spec/ruby/library/digest/sha2/hexdigest_spec.rb @@ -0,0 +1,32 @@ +require_relative '../../../spec_helper' +require_relative '../sha256/shared/constants' + +describe "Digest::SHA2#hexdigest" do + + it "returns a SHA256 hexdigest by default" do + cur_digest = Digest::SHA2.new + cur_digest.hexdigest.should == SHA256Constants::BlankHexdigest + + # add something to check that the state is reset later + cur_digest << "test" + + cur_digest.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest + # second invocation is intentional, to make sure there are no side-effects + cur_digest.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest + + # after all is done, verify that the digest is in the original, blank state + cur_digest.hexdigest.should == SHA256Constants::BlankHexdigest + end + +end + +describe "Digest::SHA2.hexdigest" do + + it "returns a SHA256 hexdigest by default" do + Digest::SHA2.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest + # second invocation is intentional, to make sure there are no side-effects + Digest::SHA2.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest + Digest::SHA2.hexdigest("").should == SHA256Constants::BlankHexdigest + end + +end diff --git a/spec/ruby/library/digest/sha256/append_spec.rb b/spec/ruby/library/digest/sha256/append_spec.rb index 53e623743a..ab594c105f 100644 --- a/spec/ruby/library/digest/sha256/append_spec.rb +++ b/spec/ruby/library/digest/sha256/append_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA256#<<" do - it_behaves_like(:sha256_update, :<<) + it_behaves_like :sha256_update, :<< end diff --git a/spec/ruby/library/digest/sha256/block_length_spec.rb b/spec/ruby/library/digest/sha256/block_length_spec.rb index 4fea959da1..1e29e832cf 100644 --- a/spec/ruby/library/digest/sha256/block_length_spec.rb +++ b/spec/ruby/library/digest/sha256/block_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#block_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA256#block_length" do end end - diff --git a/spec/ruby/library/digest/sha256/digest_bang_spec.rb b/spec/ruby/library/digest/sha256/digest_bang_spec.rb index b876c2ceed..690442221a 100644 --- a/spec/ruby/library/digest/sha256/digest_bang_spec.rb +++ b/spec/ruby/library/digest/sha256/digest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#digest!" do diff --git a/spec/ruby/library/digest/sha256/digest_length_spec.rb b/spec/ruby/library/digest/sha256/digest_length_spec.rb index f3d0d66877..b5c8958e84 100644 --- a/spec/ruby/library/digest/sha256/digest_length_spec.rb +++ b/spec/ruby/library/digest/sha256/digest_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#digest_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA256#digest_length" do end end - diff --git a/spec/ruby/library/digest/sha256/digest_spec.rb b/spec/ruby/library/digest/sha256/digest_spec.rb index de30916d57..1e79f25627 100644 --- a/spec/ruby/library/digest/sha256/digest_spec.rb +++ b/spec/ruby/library/digest/sha256/digest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#digest" do diff --git a/spec/ruby/library/digest/sha256/equal_spec.rb b/spec/ruby/library/digest/sha256/equal_spec.rb index 7932b6c13d..84662aa068 100644 --- a/spec/ruby/library/digest/sha256/equal_spec.rb +++ b/spec/ruby/library/digest/sha256/equal_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#==" do @@ -34,4 +34,3 @@ describe "Digest::SHA256#==" do end end - diff --git a/spec/ruby/library/digest/sha256/file_spec.rb b/spec/ruby/library/digest/sha256/file_spec.rb index a52b7939f3..d67a9ebcd6 100644 --- a/spec/ruby/library/digest/sha256/file_spec.rb +++ b/spec/ruby/library/digest/sha256/file_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../../../../core/file/shared/read', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative '../../../core/file/shared/read' describe "Digest::SHA256.file" do @@ -15,18 +15,22 @@ 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 Digest::SHA256.file(@file).digest.should == SHA256Constants::Digest end + it "can be used with frozen-string-literal" do + ruby_exe("require 'digest'; puts Digest::SHA256.file(#{@file.inspect}).digest.inspect", options: "--enable=frozen-string-literal").chomp.should == SHA256Constants::Digest.inspect + end + it "calls #to_str on an object and returns the Digest::SHA256 with the result" 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 @@ -34,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 - lambda { Digest::SHA256.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA256.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - lambda { 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/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb index 98bf38f773..1acd8043b3 100644 --- a/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb +++ b/spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#hexdigest!" do diff --git a/spec/ruby/library/digest/sha256/hexdigest_spec.rb b/spec/ruby/library/digest/sha256/hexdigest_spec.rb index 3ee7844a93..4f748b33b4 100644 --- a/spec/ruby/library/digest/sha256/hexdigest_spec.rb +++ b/spec/ruby/library/digest/sha256/hexdigest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#hexdigest" do diff --git a/spec/ruby/library/digest/sha256/inspect_spec.rb b/spec/ruby/library/digest/sha256/inspect_spec.rb index 5e44b58c63..ed606e4517 100644 --- a/spec/ruby/library/digest/sha256/inspect_spec.rb +++ b/spec/ruby/library/digest/sha256/inspect_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#inspect" do @@ -9,4 +9,3 @@ describe "Digest::SHA256#inspect" do end end - diff --git a/spec/ruby/library/digest/sha256/length_spec.rb b/spec/ruby/library/digest/sha256/length_spec.rb index 6760511093..181ac564ad 100644 --- a/spec/ruby/library/digest/sha256/length_spec.rb +++ b/spec/ruby/library/digest/sha256/length_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA256#length" do it_behaves_like :sha256_length, :length end - diff --git a/spec/ruby/library/digest/sha256/reset_spec.rb b/spec/ruby/library/digest/sha256/reset_spec.rb index 82bb08d354..f0eb4faea6 100644 --- a/spec/ruby/library/digest/sha256/reset_spec.rb +++ b/spec/ruby/library/digest/sha256/reset_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#reset" do @@ -12,4 +12,3 @@ describe "Digest::SHA256#reset" do end end - diff --git a/spec/ruby/library/digest/sha256/shared/constants.rb b/spec/ruby/library/digest/sha256/shared/constants.rb index dd5b48dca9..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' @@ -13,5 +13,6 @@ module SHA256Constants Digest = "\230b\265\344_\337\357\337\242\004\314\311A\211jb\350\373\254\370\365M\230B\002\372\020j\as\270\376" BlankHexdigest = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" Hexdigest = "9862b5e45fdfefdfa204ccc941896a62e8fbacf8f54d984202fa106a0773b8fe" + Base64digest = "mGK15F/f79+iBMzJQYlqYuj7rPj1TZhCAvoQagdzuP4=" end diff --git a/spec/ruby/library/digest/sha256/size_spec.rb b/spec/ruby/library/digest/sha256/size_spec.rb index 77db876956..1028263342 100644 --- a/spec/ruby/library/digest/sha256/size_spec.rb +++ b/spec/ruby/library/digest/sha256/size_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA256#size" do it_behaves_like :sha256_length, :size end - diff --git a/spec/ruby/library/digest/sha256/to_s_spec.rb b/spec/ruby/library/digest/sha256/to_s_spec.rb index b91983d157..8bedee3f98 100644 --- a/spec/ruby/library/digest/sha256/to_s_spec.rb +++ b/spec/ruby/library/digest/sha256/to_s_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA256#to_s" do diff --git a/spec/ruby/library/digest/sha256/update_spec.rb b/spec/ruby/library/digest/sha256/update_spec.rb index 3e3eaf57a3..92316eb752 100644 --- a/spec/ruby/library/digest/sha256/update_spec.rb +++ b/spec/ruby/library/digest/sha256/update_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA256#update" do it_behaves_like :sha256_update, :update diff --git a/spec/ruby/library/digest/sha384/append_spec.rb b/spec/ruby/library/digest/sha384/append_spec.rb index d694812e85..94c036cc3f 100644 --- a/spec/ruby/library/digest/sha384/append_spec.rb +++ b/spec/ruby/library/digest/sha384/append_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA384#<<" do - it_behaves_like(:sha384_update, :<<) + it_behaves_like :sha384_update, :<< end diff --git a/spec/ruby/library/digest/sha384/block_length_spec.rb b/spec/ruby/library/digest/sha384/block_length_spec.rb index 070715b27e..dff645ffb9 100644 --- a/spec/ruby/library/digest/sha384/block_length_spec.rb +++ b/spec/ruby/library/digest/sha384/block_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#block_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA384#block_length" do end end - diff --git a/spec/ruby/library/digest/sha384/digest_bang_spec.rb b/spec/ruby/library/digest/sha384/digest_bang_spec.rb index 83b68ae7c2..8711913deb 100644 --- a/spec/ruby/library/digest/sha384/digest_bang_spec.rb +++ b/spec/ruby/library/digest/sha384/digest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#digest!" do diff --git a/spec/ruby/library/digest/sha384/digest_length_spec.rb b/spec/ruby/library/digest/sha384/digest_length_spec.rb index a57616b44c..4067dd34af 100644 --- a/spec/ruby/library/digest/sha384/digest_length_spec.rb +++ b/spec/ruby/library/digest/sha384/digest_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#digest_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA384#digest_length" do end end - diff --git a/spec/ruby/library/digest/sha384/digest_spec.rb b/spec/ruby/library/digest/sha384/digest_spec.rb index 3a5cd3a5d7..d0e2825934 100644 --- a/spec/ruby/library/digest/sha384/digest_spec.rb +++ b/spec/ruby/library/digest/sha384/digest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#digest" do diff --git a/spec/ruby/library/digest/sha384/equal_spec.rb b/spec/ruby/library/digest/sha384/equal_spec.rb index a54d328edc..5d3483d79a 100644 --- a/spec/ruby/library/digest/sha384/equal_spec.rb +++ b/spec/ruby/library/digest/sha384/equal_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#==" do @@ -34,4 +34,3 @@ describe "Digest::SHA384#==" do end end - diff --git a/spec/ruby/library/digest/sha384/file_spec.rb b/spec/ruby/library/digest/sha384/file_spec.rb index 7e7c8f9565..3726ad4423 100644 --- a/spec/ruby/library/digest/sha384/file_spec.rb +++ b/spec/ruby/library/digest/sha384/file_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../../../../core/file/shared/read', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative '../../../core/file/shared/read' describe "Digest::SHA384.file" do @@ -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 - lambda { Digest::SHA384.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA384.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - lambda { 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/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb index 68da8c7200..8efceec3eb 100644 --- a/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb +++ b/spec/ruby/library/digest/sha384/hexdigest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#hexdigest!" do diff --git a/spec/ruby/library/digest/sha384/hexdigest_spec.rb b/spec/ruby/library/digest/sha384/hexdigest_spec.rb index a7724d1663..07ea05c541 100644 --- a/spec/ruby/library/digest/sha384/hexdigest_spec.rb +++ b/spec/ruby/library/digest/sha384/hexdigest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#hexdigest" do diff --git a/spec/ruby/library/digest/sha384/inspect_spec.rb b/spec/ruby/library/digest/sha384/inspect_spec.rb index 554a22d135..8f9f946cc5 100644 --- a/spec/ruby/library/digest/sha384/inspect_spec.rb +++ b/spec/ruby/library/digest/sha384/inspect_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#inspect" do @@ -9,4 +9,3 @@ describe "Digest::SHA384#inspect" do end end - diff --git a/spec/ruby/library/digest/sha384/length_spec.rb b/spec/ruby/library/digest/sha384/length_spec.rb index 63a57ce9ca..33fed492ef 100644 --- a/spec/ruby/library/digest/sha384/length_spec.rb +++ b/spec/ruby/library/digest/sha384/length_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA384#length" do it_behaves_like :sha384_length, :length end - diff --git a/spec/ruby/library/digest/sha384/reset_spec.rb b/spec/ruby/library/digest/sha384/reset_spec.rb index 8abe39d7e2..991b90903d 100644 --- a/spec/ruby/library/digest/sha384/reset_spec.rb +++ b/spec/ruby/library/digest/sha384/reset_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#reset" do @@ -12,4 +12,3 @@ describe "Digest::SHA384#reset" do end end - diff --git a/spec/ruby/library/digest/sha384/shared/constants.rb b/spec/ruby/library/digest/sha384/shared/constants.rb index 3697384fc3..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' @@ -14,5 +14,6 @@ module SHA384Constants Digest = "B&\266:\314\216z\361!TD\001{`\355\323\320MW%\270\272\0034n\034\026g\a\217\"\333s\202\275\002Y*\217]\207u\f\034\244\231\266f" BlankHexdigest = "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" Hexdigest = "4226b63acc8e7af1215444017b60edd3d04d5725b8ba03346e1c1667078f22db7382bd02592a8f5d87750c1ca499b666" + Base64digest = "Qia2OsyOevEhVEQBe2Dt09BNVyW4ugM0bhwWZwePIttzgr0CWSqPXYd1DBykmbZm" end diff --git a/spec/ruby/library/digest/sha384/size_spec.rb b/spec/ruby/library/digest/sha384/size_spec.rb index 9aea3ef592..4c3b14f7a0 100644 --- a/spec/ruby/library/digest/sha384/size_spec.rb +++ b/spec/ruby/library/digest/sha384/size_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA384#size" do it_behaves_like :sha384_length, :size end - diff --git a/spec/ruby/library/digest/sha384/to_s_spec.rb b/spec/ruby/library/digest/sha384/to_s_spec.rb index f45f2ee915..68ea9c013f 100644 --- a/spec/ruby/library/digest/sha384/to_s_spec.rb +++ b/spec/ruby/library/digest/sha384/to_s_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA384#to_s" do diff --git a/spec/ruby/library/digest/sha384/update_spec.rb b/spec/ruby/library/digest/sha384/update_spec.rb index 9917f86b86..a1d0dd6068 100644 --- a/spec/ruby/library/digest/sha384/update_spec.rb +++ b/spec/ruby/library/digest/sha384/update_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA384#update" do it_behaves_like :sha384_update, :update diff --git a/spec/ruby/library/digest/sha512/append_spec.rb b/spec/ruby/library/digest/sha512/append_spec.rb index 642e565bf6..9106e9685d 100644 --- a/spec/ruby/library/digest/sha512/append_spec.rb +++ b/spec/ruby/library/digest/sha512/append_spec.rb @@ -1,7 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA512#<<" do - it_behaves_like(:sha512_update, :<<) + it_behaves_like :sha512_update, :<< end diff --git a/spec/ruby/library/digest/sha512/block_length_spec.rb b/spec/ruby/library/digest/sha512/block_length_spec.rb index 95bb98548a..947af841dd 100644 --- a/spec/ruby/library/digest/sha512/block_length_spec.rb +++ b/spec/ruby/library/digest/sha512/block_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#block_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA512#block_length" do end end - diff --git a/spec/ruby/library/digest/sha512/digest_bang_spec.rb b/spec/ruby/library/digest/sha512/digest_bang_spec.rb index 260595152d..981570b907 100644 --- a/spec/ruby/library/digest/sha512/digest_bang_spec.rb +++ b/spec/ruby/library/digest/sha512/digest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#digest!" do diff --git a/spec/ruby/library/digest/sha512/digest_length_spec.rb b/spec/ruby/library/digest/sha512/digest_length_spec.rb index 5185b6e906..ff5956dd75 100644 --- a/spec/ruby/library/digest/sha512/digest_length_spec.rb +++ b/spec/ruby/library/digest/sha512/digest_length_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#digest_length" do @@ -9,4 +9,3 @@ describe "Digest::SHA512#digest_length" do end end - diff --git a/spec/ruby/library/digest/sha512/digest_spec.rb b/spec/ruby/library/digest/sha512/digest_spec.rb index 9f4264579f..092efccc62 100644 --- a/spec/ruby/library/digest/sha512/digest_spec.rb +++ b/spec/ruby/library/digest/sha512/digest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#digest" do diff --git a/spec/ruby/library/digest/sha512/equal_spec.rb b/spec/ruby/library/digest/sha512/equal_spec.rb index ec4c55f118..5100ced6e8 100644 --- a/spec/ruby/library/digest/sha512/equal_spec.rb +++ b/spec/ruby/library/digest/sha512/equal_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#==" do @@ -34,4 +34,3 @@ describe "Digest::SHA512#==" do end end - diff --git a/spec/ruby/library/digest/sha512/file_spec.rb b/spec/ruby/library/digest/sha512/file_spec.rb index 365f3625b6..78d6d3d4f3 100644 --- a/spec/ruby/library/digest/sha512/file_spec.rb +++ b/spec/ruby/library/digest/sha512/file_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../../../../core/file/shared/read', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative '../../../core/file/shared/read' describe "Digest::SHA512.file" do @@ -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 - lambda { Digest::SHA512.file("") }.should raise_error(Errno::ENOENT) + -> { Digest::SHA512.file("") }.should.raise(Errno::ENOENT) end it "raises a TypeError when passed nil" do - lambda { 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/hexdigest_bang_spec.rb b/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb index 6eda150949..e9b0da6191 100644 --- a/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb +++ b/spec/ruby/library/digest/sha512/hexdigest_bang_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#hexdigest!" do diff --git a/spec/ruby/library/digest/sha512/hexdigest_spec.rb b/spec/ruby/library/digest/sha512/hexdigest_spec.rb index 405d380490..6e1dc3c642 100644 --- a/spec/ruby/library/digest/sha512/hexdigest_spec.rb +++ b/spec/ruby/library/digest/sha512/hexdigest_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#hexdigest" do diff --git a/spec/ruby/library/digest/sha512/inspect_spec.rb b/spec/ruby/library/digest/sha512/inspect_spec.rb index 97806000d2..54a466043a 100644 --- a/spec/ruby/library/digest/sha512/inspect_spec.rb +++ b/spec/ruby/library/digest/sha512/inspect_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#inspect" do @@ -9,4 +9,3 @@ describe "Digest::SHA512#inspect" do end end - diff --git a/spec/ruby/library/digest/sha512/length_spec.rb b/spec/ruby/library/digest/sha512/length_spec.rb index b0b4d7e56c..e9fde90577 100644 --- a/spec/ruby/library/digest/sha512/length_spec.rb +++ b/spec/ruby/library/digest/sha512/length_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA512#length" do it_behaves_like :sha512_length, :length end - diff --git a/spec/ruby/library/digest/sha512/reset_spec.rb b/spec/ruby/library/digest/sha512/reset_spec.rb index b2f28dc670..24a936d4ba 100644 --- a/spec/ruby/library/digest/sha512/reset_spec.rb +++ b/spec/ruby/library/digest/sha512/reset_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#reset" do @@ -12,4 +12,3 @@ describe "Digest::SHA512#reset" do end end - diff --git a/spec/ruby/library/digest/sha512/shared/constants.rb b/spec/ruby/library/digest/sha512/shared/constants.rb index 80f5b7bc1d..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' @@ -13,5 +13,6 @@ module SHA512Constants Digest = "\241\231\232\365\002z\241\331\242\310=\367F\272\004\326\331g\315n\251Q\222\250\374E\257\254=\325\225\003SM\350\244\234\220\233=\031\230A;\000\203\233\340\323t\333\271\222w\266\307\2678\344\255j\003\216\300" BlankHexdigest = "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" Hexdigest = "a1999af5027aa1d9a2c83df746ba04d6d967cd6ea95192a8fc45afac3dd59503534de8a49c909b3d1998413b00839be0d374dbb99277b6c7b738e4ad6a038ec0" + Base64digest = "oZma9QJ6odmiyD33RroE1tlnzW6pUZKo/EWvrD3VlQNTTeiknJCbPRmYQTsAg5vg03TbuZJ3tse3OOStagOOwA==" end diff --git a/spec/ruby/library/digest/sha512/size_spec.rb b/spec/ruby/library/digest/sha512/size_spec.rb index a882fe55a1..6d0acdabdb 100644 --- a/spec/ruby/library/digest/sha512/size_spec.rb +++ b/spec/ruby/library/digest/sha512/size_spec.rb @@ -1,8 +1,7 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/length', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/length' describe "Digest::SHA512#size" do it_behaves_like :sha512_length, :size end - diff --git a/spec/ruby/library/digest/sha512/to_s_spec.rb b/spec/ruby/library/digest/sha512/to_s_spec.rb index b45f553e8c..68d86241c9 100644 --- a/spec/ruby/library/digest/sha512/to_s_spec.rb +++ b/spec/ruby/library/digest/sha512/to_s_spec.rb @@ -1,5 +1,5 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' describe "Digest::SHA512#to_s" do diff --git a/spec/ruby/library/digest/sha512/update_spec.rb b/spec/ruby/library/digest/sha512/update_spec.rb index 3b82f51853..682d3a19bb 100644 --- a/spec/ruby/library/digest/sha512/update_spec.rb +++ b/spec/ruby/library/digest/sha512/update_spec.rb @@ -1,6 +1,6 @@ -require File.expand_path('../../../../spec_helper', __FILE__) -require File.expand_path('../shared/constants', __FILE__) -require File.expand_path('../shared/update', __FILE__) +require_relative '../../../spec_helper' +require_relative 'shared/constants' +require_relative 'shared/update' describe "Digest::SHA512#update" do it_behaves_like :sha512_update, :update |
