spec/string_spec.rb in dionysus-0.2.1 vs spec/string_spec.rb in dionysus-0.3.0
- old
+ new
@@ -22,6 +22,25 @@
it "should decode_hex" do
'6162636465a07a343035'.decode_hex.should == "abcde\240z405"
'6162636465a07a343035'.decode_hexidecimal.should == "abcde\240z405"
end
-end
\ No newline at end of file
+
+ describe 'encoding detection' do
+ it 'should return nil for blank' do
+ ''.detect_encoding.should be_nil
+ end
+
+ it 'should match hex' do
+ '6162636465a07a343035'.detect_encoding.should == :hex
+ end
+
+ it 'should match base64' do
+ "YWJjZGWgejQwNQ==".detect_encoding.should == :base64
+ "YWJjZGWgejQwNQ==\n".detect_encoding.should == :base64
+ end
+
+ it 'should default to binary' do
+ "abcde\240z405".detect_encoding.should == :binary
+ end
+ end
+end