summaryrefslogtreecommitdiff
path: root/spec/ruby/library/digest/sha256
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/digest/sha256')
-rw-r--r--spec/ruby/library/digest/sha256/append_spec.rb7
-rw-r--r--spec/ruby/library/digest/sha256/file_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha256/length_spec.rb8
-rw-r--r--spec/ruby/library/digest/sha256/shared/constants.rb2
-rw-r--r--spec/ruby/library/digest/sha256/shared/length.rb8
-rw-r--r--spec/ruby/library/digest/sha256/shared/update.rb7
-rw-r--r--spec/ruby/library/digest/sha256/size_spec.rb5
-rw-r--r--spec/ruby/library/digest/sha256/update_spec.rb7
8 files changed, 23 insertions, 29 deletions
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