diff options
Diffstat (limited to 'spec/ruby/core/string/crypt_spec.rb')
| -rw-r--r-- | spec/ruby/core/string/crypt_spec.rb | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/spec/ruby/core/string/crypt_spec.rb b/spec/ruby/core/string/crypt_spec.rb index 66161b280f..06f84c70a4 100644 --- a/spec/ruby/core/string/crypt_spec.rb +++ b/spec/ruby/core/string/crypt_spec.rb @@ -15,7 +15,7 @@ describe "String#crypt" do end it "raises Errno::EINVAL when the salt is shorter than 29 characters" do - lambda { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL) + -> { "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHW") }.should raise_error(Errno::EINVAL) end it "calls #to_str to converts the salt arg to a String" do @@ -25,19 +25,6 @@ describe "String#crypt" do "mypassword".crypt(obj).should == "$2a$04$0WVaz0pV3jzfZ5G5tpmHWuBQGbkjzgtSc3gJbmdy0GAGMa45MFM2." end - it "taints the result if either salt or self is tainted" do - tainted_salt = "$2a$04$0WVaz0pV3jzfZ5G5tpmHWu" - tainted_str = "mypassword" - - tainted_salt.taint - tainted_str.taint - - "mypassword".crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == false - tainted_str.crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").tainted?.should == true - "mypassword".crypt(tainted_salt).tainted?.should == true - tainted_str.crypt(tainted_salt).tainted?.should == true - end - it "doesn't return subclass instances" do StringSpecs::MyString.new("mypassword").crypt("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu").should be_an_instance_of(String) "mypassword".crypt(StringSpecs::MyString.new("$2a$04$0WVaz0pV3jzfZ5G5tpmHWu")).should be_an_instance_of(String) @@ -73,7 +60,7 @@ describe "String#crypt" do end it "raises an ArgumentError when the string contains NUL character" do - lambda { "poison\0null".crypt("aa") }.should raise_error(ArgumentError) + -> { "poison\0null".crypt("aa") }.should raise_error(ArgumentError) end it "calls #to_str to converts the salt arg to a String" do @@ -83,19 +70,6 @@ describe "String#crypt" do "".crypt(obj).should == "aaQSqAReePlq6" end - it "taints the result if either salt or self is tainted" do - tainted_salt = "aa" - tainted_str = "hello" - - tainted_salt.taint - tainted_str.taint - - "hello".crypt("aa").tainted?.should == false - tainted_str.crypt("aa").tainted?.should == true - "hello".crypt(tainted_salt).tainted?.should == true - tainted_str.crypt(tainted_salt).tainted?.should == true - end - it "doesn't return subclass instances" do StringSpecs::MyString.new("hello").crypt("aa").should be_an_instance_of(String) "hello".crypt(StringSpecs::MyString.new("aa")).should be_an_instance_of(String) @@ -103,16 +77,16 @@ describe "String#crypt" do end it "raises an ArgumentError when the salt is shorter than two characters" do - lambda { "hello".crypt("") }.should raise_error(ArgumentError) - lambda { "hello".crypt("f") }.should raise_error(ArgumentError) - lambda { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError) - lambda { "hello".crypt("\x00a") }.should raise_error(ArgumentError) - lambda { "hello".crypt("a\x00") }.should raise_error(ArgumentError) + -> { "hello".crypt("") }.should raise_error(ArgumentError) + -> { "hello".crypt("f") }.should raise_error(ArgumentError) + -> { "hello".crypt("\x00\x00") }.should raise_error(ArgumentError) + -> { "hello".crypt("\x00a") }.should raise_error(ArgumentError) + -> { "hello".crypt("a\x00") }.should raise_error(ArgumentError) end end it "raises a type error when the salt arg can't be converted to a string" do - lambda { "".crypt(5) }.should raise_error(TypeError) - lambda { "".crypt(mock('x')) }.should raise_error(TypeError) + -> { "".crypt(5) }.should raise_error(TypeError) + -> { "".crypt(mock('x')) }.should raise_error(TypeError) end end |
