/vendor/bundle/jruby/2.1/gems/rbnacl-3.0.1/spec/shared/key_equality.rb

https://github.com/delowong/logstash · Ruby · 26 lines · 24 code · 1 blank · 1 comment · 4 complexity · 9e73071180f89fdac3071cfdd94d6808 MD5 · raw file

  1. # encoding: binary
  2. shared_examples "key equality" do
  3. context "equality" do
  4. it "equal keys are equal" do
  5. (described_class.new(key_bytes) == key).should be true
  6. end
  7. it "equal keys are equal to the string" do
  8. (key == key_bytes).should be true
  9. end
  10. it "keys are not equal to zero" do
  11. (key == RbNaCl::Util.zeros(32)).should be false
  12. end
  13. it "keys are not equal to another key" do
  14. (key == other_key).should be false
  15. end
  16. end
  17. context "lexicographic sorting" do
  18. it "can be compared lexicographically to a key smaller than it" do
  19. (key > RbNaCl::Util.zeros(32)).should be true
  20. end
  21. it "can be compared lexicographically to a key larger than it" do
  22. (described_class.new(RbNaCl::Util.zeros(32)) < key).should be true
  23. end
  24. end
  25. end