summaryrefslogtreecommitdiff
path: root/spec/ruby/library/digest/instance
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/digest/instance')
-rw-r--r--spec/ruby/library/digest/instance/append_spec.rb11
-rw-r--r--spec/ruby/library/digest/instance/new_spec.rb19
-rw-r--r--spec/ruby/library/digest/instance/update_spec.rb8
3 files changed, 38 insertions, 0 deletions
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..7f4ce3d121
--- /dev/null
+++ b/spec/ruby/library/digest/instance/append_spec.rb
@@ -0,0 +1,11 @@
+require_relative '../../../spec_helper'
+require 'digest'
+
+describe "Digest::Instance#<<" do
+ 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/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/update_spec.rb b/spec/ruby/library/digest/instance/update_spec.rb
new file mode 100644
index 0000000000..d15b976213
--- /dev/null
+++ b/spec/ruby/library/digest/instance/update_spec.rb
@@ -0,0 +1,8 @@
+require_relative '../../../spec_helper'
+require 'digest'
+
+describe "Digest::Instance#update" do
+ it "is an alias of Digest::Instance#<<" do
+ Digest::Instance.instance_method(:update).should == Digest::Instance.instance_method(:<<)
+ end
+end