spec/helpers/string_spec.rb in encryption-1.1.3 vs spec/helpers/string_spec.rb in encryption-1.1.4
- old
+ new
@@ -58,6 +58,29 @@
it 'should decrypt, encrypted values and match the original string' do
@string.encrypt(@options).decrypt(@options).should == @string
end
end
+ describe 'with encode option' do
+ before(:each) do
+ @string = String.random
+ @options = {
+ :key => String.random,
+ :iv => String.random,
+ :encode => true
+ }
+ end
+
+ it 'should generate encryption different then the original string' do
+ @string.encrypt(@options).should_not == @string
+ end
+
+ it 'should generate a valid base64' do
+ (@string.encrypt(@options)=~/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/).should == 0
+ end
+
+ it 'should decrypt, encrypted values and match the original string' do
+ @string.encrypt(@options).decrypt(@options).should == @string
+ end
+ end
+
end
\ No newline at end of file