PageRenderTime 55ms CodeModel.GetById 33ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/bundle/jruby/2.1/gems/rbnacl-3.0.1/spec/rbnacl/boxes/curve25519xsalsa20poly1305/public_key_spec.rb

https://github.com/delowong/logstash
Ruby | 42 lines | 32 code | 9 blank | 1 comment | 0 complexity | d430cb9a6e01e5def68242e40f53c082 MD5 | raw file
 1# encoding: binary
 2require 'spec_helper'
 3
 4describe RbNaCl::PublicKey do
 5  let(:alicepk)     { vector :alice_public }
 6
 7  subject { RbNaCl::PublicKey.new(alicepk) }
 8
 9  context "new" do
10    it "accepts a valid key" do
11      expect { RbNaCl::PublicKey.new(alicepk) }.not_to raise_error
12    end
13
14    it "rejects a nil key" do
15      expect { RbNaCl::PublicKey.new(nil) }.to raise_error(TypeError)
16    end
17
18    it "rejects a short key" do
19      expect { RbNaCl::PublicKey.new("short") }.to raise_error(ArgumentError)
20    end
21  end
22
23  context "#to_bytes" do
24    it "returns the bytes of the key" do
25      subject.to_bytes.should eq alicepk
26    end
27  end
28
29  context "#to_s" do
30    it "returns the bytes of the key" do
31      subject.to_s.should eq alicepk
32    end
33  end
34
35  include_examples "key equality" do
36    let(:key) { subject }
37    let(:key_bytes) { subject.to_bytes }
38    let(:other_key) { described_class.new(alicepk.succ) }
39  end
40
41  include_examples "serializable"
42end