summaryrefslogtreecommitdiff
path: root/spec/ruby/library/digest/md5
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/digest/md5')
-rw-r--r--spec/ruby/library/digest/md5/append_spec.rb7
-rw-r--r--spec/ruby/library/digest/md5/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/md5/length_spec.rb8
-rw-r--r--spec/ruby/library/digest/md5/shared/constants.rb3
-rw-r--r--spec/ruby/library/digest/md5/shared/length.rb8
-rw-r--r--spec/ruby/library/digest/md5/shared/sample.rb17
-rw-r--r--spec/ruby/library/digest/md5/shared/update.rb7
-rw-r--r--spec/ruby/library/digest/md5/size_spec.rb5
-rw-r--r--spec/ruby/library/digest/md5/update_spec.rb7
9 files changed, 24 insertions, 46 deletions
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 2684f50373..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
- 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/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 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/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/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/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