spec/string_security_spec.rb in dionysus-0.3.0 vs spec/string_security_spec.rb in dionysus-0.3.1

- old
+ new

@@ -177,6 +177,28 @@ it "should calculate md5 in binary" do digest = "N\024\364\313\262\233\002)\343.\233\202\206\253\021\271" "abcde\240z405".digest(:md5, :encoding => :binary).should == digest "abcde\240z405".md5(:encoding => :binary).should == digest end + + it "should fallback to super method missing with unavailable digest" do + lambda { "abcde\240z405".my_digest }.should raise_error(NoMethodError) + end + + it "should raise an error with invalid encoding" do + lambda { "abcde\240z405".md5(:encoding => :foobar) }.should raise_error(ArgumentError, 'Invalid encoding: foobar') + end + + describe "digest detection" do + it "should defer to Digest" do + str = "abcde\240z405" + Digest.should_receive(:detect_digest).with(str, :binary) + str.detect_digest(:binary) + end + + it "should defer to Digest" do + str = "abcde\240z405" + Digest.should_receive(:detect_digest!).with(str, :binary) + str.detect_digest!(:binary) + end + end end