mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory. [Misc #13792] [ruby-core:82287] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
75bfc6440d
commit
1d15d5f080
4370 changed files with 0 additions and 0 deletions
7
spec/ruby/library/digest/sha256/append_spec.rb
Normal file
7
spec/ruby/library/digest/sha256/append_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#<<" do
|
||||
it_behaves_like(:sha256_update, :<<)
|
||||
end
|
12
spec/ruby/library/digest/sha256/block_length_spec.rb
Normal file
12
spec/ruby/library/digest/sha256/block_length_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#block_length" do
|
||||
|
||||
it "returns the length of digest block" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.block_length.should == SHA256Constants::BlockLength
|
||||
end
|
||||
|
||||
end
|
||||
|
13
spec/ruby/library/digest/sha256/digest_bang_spec.rb
Normal file
13
spec/ruby/library/digest/sha256/digest_bang_spec.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#digest!" do
|
||||
|
||||
it "returns a digest and can digest!" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest << SHA256Constants::Contents
|
||||
cur_digest.digest!().should == SHA256Constants::Digest
|
||||
cur_digest.digest().should == SHA256Constants::BlankDigest
|
||||
end
|
||||
|
||||
end
|
12
spec/ruby/library/digest/sha256/digest_length_spec.rb
Normal file
12
spec/ruby/library/digest/sha256/digest_length_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#digest_length" do
|
||||
|
||||
it "returns the length of computed digests" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.digest_length.should == SHA256Constants::DigestLength
|
||||
end
|
||||
|
||||
end
|
||||
|
32
spec/ruby/library/digest/sha256/digest_spec.rb
Normal file
32
spec/ruby/library/digest/sha256/digest_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#digest" do
|
||||
|
||||
it "returns a digest" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.digest().should == SHA256Constants::BlankDigest
|
||||
|
||||
# add something to check that the state is reset later
|
||||
cur_digest << "test"
|
||||
|
||||
cur_digest.digest(SHA256Constants::Contents).should == SHA256Constants::Digest
|
||||
# second invocation is intentional, to make sure there are no side-effects
|
||||
cur_digest.digest(SHA256Constants::Contents).should == SHA256Constants::Digest
|
||||
|
||||
# after all is done, verify that the digest is in the original, blank state
|
||||
cur_digest.digest.should == SHA256Constants::BlankDigest
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "Digest::SHA256.digest" do
|
||||
|
||||
it "returns a digest" do
|
||||
Digest::SHA256.digest(SHA256Constants::Contents).should == SHA256Constants::Digest
|
||||
# second invocation is intentional, to make sure there are no side-effects
|
||||
Digest::SHA256.digest(SHA256Constants::Contents).should == SHA256Constants::Digest
|
||||
Digest::SHA256.digest("").should == SHA256Constants::BlankDigest
|
||||
end
|
||||
|
||||
end
|
37
spec/ruby/library/digest/sha256/equal_spec.rb
Normal file
37
spec/ruby/library/digest/sha256/equal_spec.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#==" do
|
||||
|
||||
it "equals itself" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.should == cur_digest
|
||||
end
|
||||
|
||||
it "equals the string representing its hexdigest" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.should == SHA256Constants::BlankHexdigest
|
||||
end
|
||||
|
||||
it "equals the appropriate object that responds to to_str" do
|
||||
# blank digest
|
||||
cur_digest = Digest::SHA256.new
|
||||
(obj = mock(SHA256Constants::BlankHexdigest)).should_receive(:to_str).and_return(SHA256Constants::BlankHexdigest)
|
||||
cur_digest.should == obj
|
||||
|
||||
# non-blank digest
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest << "test"
|
||||
d_value = cur_digest.hexdigest
|
||||
(obj = mock(d_value)).should_receive(:to_str).and_return(d_value)
|
||||
cur_digest.should == obj
|
||||
end
|
||||
|
||||
it "equals the same digest for a different object" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest2 = Digest::SHA256.new
|
||||
cur_digest.should == cur_digest2
|
||||
end
|
||||
|
||||
end
|
||||
|
43
spec/ruby/library/digest/sha256/file_spec.rb
Normal file
43
spec/ruby/library/digest/sha256/file_spec.rb
Normal file
|
@ -0,0 +1,43 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
require File.expand_path('../../../../core/file/shared/read', __FILE__)
|
||||
|
||||
describe "Digest::SHA256.file" do
|
||||
|
||||
describe "when passed a path to a file that exists" do
|
||||
before :each do
|
||||
@file = tmp("md5_temp")
|
||||
touch(@file, 'wb') {|f| f.write SHA256Constants::Contents }
|
||||
end
|
||||
|
||||
after :each do
|
||||
rm_r @file
|
||||
end
|
||||
|
||||
it "returns a Digest::SHA256 object" do
|
||||
Digest::SHA256.file(@file).should be_kind_of(Digest::SHA256)
|
||||
end
|
||||
|
||||
it "returns a Digest::SHA256 object with the correct digest" do
|
||||
Digest::SHA256.file(@file).digest.should == SHA256Constants::Digest
|
||||
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.digest.should == SHA256Constants::Digest
|
||||
end
|
||||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
it "raises a TypeError when passed nil" do
|
||||
lambda { Digest::SHA256.file(nil) }.should raise_error(TypeError)
|
||||
end
|
||||
end
|
14
spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb
Normal file
14
spec/ruby/library/digest/sha256/hexdigest_bang_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#hexdigest!" do
|
||||
|
||||
it "returns a hexdigest and resets the state" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
|
||||
cur_digest << SHA256Constants::Contents
|
||||
cur_digest.hexdigest!.should == SHA256Constants::Hexdigest
|
||||
cur_digest.hexdigest.should == SHA256Constants::BlankHexdigest
|
||||
end
|
||||
|
||||
end
|
32
spec/ruby/library/digest/sha256/hexdigest_spec.rb
Normal file
32
spec/ruby/library/digest/sha256/hexdigest_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#hexdigest" do
|
||||
|
||||
it "returns a hexdigest" do
|
||||
cur_digest = Digest::SHA256.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::SHA256.hexdigest" do
|
||||
|
||||
it "returns a hexdigest" do
|
||||
Digest::SHA256.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest
|
||||
# second invocation is intentional, to make sure there are no side-effects
|
||||
Digest::SHA256.hexdigest(SHA256Constants::Contents).should == SHA256Constants::Hexdigest
|
||||
Digest::SHA256.hexdigest("").should == SHA256Constants::BlankHexdigest
|
||||
end
|
||||
|
||||
end
|
12
spec/ruby/library/digest/sha256/inspect_spec.rb
Normal file
12
spec/ruby/library/digest/sha256/inspect_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#inspect" do
|
||||
|
||||
it "returns a Ruby object representation" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.inspect.should == "#<#{SHA256Constants::Klass}: #{cur_digest.hexdigest()}>"
|
||||
end
|
||||
|
||||
end
|
||||
|
8
spec/ruby/library/digest/sha256/length_spec.rb
Normal file
8
spec/ruby/library/digest/sha256/length_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
require File.expand_path('../shared/length', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#length" do
|
||||
it_behaves_like :sha256_length, :length
|
||||
end
|
||||
|
15
spec/ruby/library/digest/sha256/reset_spec.rb
Normal file
15
spec/ruby/library/digest/sha256/reset_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#reset" do
|
||||
|
||||
it "returns digest state to initial conditions" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.update SHA256Constants::Contents
|
||||
cur_digest.digest().should_not == SHA256Constants::BlankDigest
|
||||
cur_digest.reset
|
||||
cur_digest.digest().should == SHA256Constants::BlankDigest
|
||||
end
|
||||
|
||||
end
|
||||
|
17
spec/ruby/library/digest/sha256/shared/constants.rb
Normal file
17
spec/ruby/library/digest/sha256/shared/constants.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# -*- encoding: binary -*-
|
||||
|
||||
require 'digest/sha2'
|
||||
|
||||
module SHA256Constants
|
||||
|
||||
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::SHA256
|
||||
BlockLength = 64
|
||||
DigestLength = 32
|
||||
BlankDigest = "\343\260\304B\230\374\034\024\232\373\364\310\231o\271$'\256A\344d\233\223L\244\225\231\exR\270U"
|
||||
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"
|
||||
|
||||
end
|
8
spec/ruby/library/digest/sha256/shared/length.rb
Normal file
8
spec/ruby/library/digest/sha256/shared/length.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
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
|
7
spec/ruby/library/digest/sha256/shared/update.rb
Normal file
7
spec/ruby/library/digest/sha256/shared/update.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
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
|
8
spec/ruby/library/digest/sha256/size_spec.rb
Normal file
8
spec/ruby/library/digest/sha256/size_spec.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
require File.expand_path('../shared/length', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#size" do
|
||||
it_behaves_like :sha256_length, :size
|
||||
end
|
||||
|
21
spec/ruby/library/digest/sha256/to_s_spec.rb
Normal file
21
spec/ruby/library/digest/sha256/to_s_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#to_s" do
|
||||
|
||||
it "returns a hexdigest" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.to_s.should == SHA256Constants::BlankHexdigest
|
||||
end
|
||||
|
||||
it "does not change the internal state" do
|
||||
cur_digest = Digest::SHA256.new
|
||||
cur_digest.to_s.should == SHA256Constants::BlankHexdigest
|
||||
cur_digest.to_s.should == SHA256Constants::BlankHexdigest
|
||||
|
||||
cur_digest << SHA256Constants::Contents
|
||||
cur_digest.to_s.should == SHA256Constants::Hexdigest
|
||||
cur_digest.to_s.should == SHA256Constants::Hexdigest
|
||||
end
|
||||
|
||||
end
|
7
spec/ruby/library/digest/sha256/update_spec.rb
Normal file
7
spec/ruby/library/digest/sha256/update_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require File.expand_path('../../../../spec_helper', __FILE__)
|
||||
require File.expand_path('../shared/constants', __FILE__)
|
||||
require File.expand_path('../shared/update', __FILE__)
|
||||
|
||||
describe "Digest::SHA256#update" do
|
||||
it_behaves_like :sha256_update, :update
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue