spec/primitives_spec.rb in simple-secrets-1.0.0 vs spec/primitives_spec.rb in simple-secrets-2.0.0
- old
+ new
@@ -211,13 +211,13 @@
it 'should correctly distinguish data equality' do
a = "11".hex_to_bin
b = "12".hex_to_bin
c = "11".hex_to_bin
- expect(Primitives.compare(a,a)).to be_true
- expect(Primitives.compare(a,b)).to be_false
- expect(Primitives.compare(a,c)).to be_true
+ expect(Primitives.compare(a,a)).to be true
+ expect(Primitives.compare(a,b)).to be false
+ expect(Primitives.compare(a,c)).to be true
end
# Timing test, in progress from node.js version
# # (node.js) This works fine locally, but has tons of variation on build server
# it 'should take just as long to compare different data as identical data', :skip => true do
@@ -328,9 +328,17 @@
it 'should return a javascript primitive or object' do
expect(Primitives.deserialize(Primitives.serialize(1))).to eq(1)
expect(Primitives.deserialize(Primitives.serialize('abcd'))).to eq('abcd')
expect(Primitives.deserialize(Primitives.serialize([]))).to eq([])
expect(Primitives.deserialize(Primitives.serialize({}))).to eq({})
+ buf = "32".hex_to_bin(10)
+ out = Primitives.deserialize(Primitives.serialize(buf))
+ expect(out).to eq(buf)
+ # msgpack bug: data is correctly extracted, but tagged with incorrect
+ # encoding. Make sure it can be coerced back.
+ if out.encoding != buf.encoding
+ expect(out.force_encoding(buf.encoding)).to eq(buf)
+ end
end
end
describe 'zero' do
it 'should require a Buffer' do