Sha256: d74f585bf4e523af19fcd344a0c23e898d57d0b4d7fb2a5412ba2332cd431d8f

Contents?: true

Size: 1.48 KB

Versions: 18

Compression:

Stored size: 1.48 KB

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/type/signature'

describe HexaPDF::Type::Signature::VerificationResult do
  describe "Message" do
    it "accepts a type and a content argument on creation" do
      m = HexaPDF::Type::Signature::VerificationResult::Message.new(:type, 'content')
      assert_equal(:type, m.type)
      assert_equal('content', m.content)
    end

    it "allows sorting by type" do
      info =  HexaPDF::Type::Signature::VerificationResult::Message.new(:info, 'c')
      warning = HexaPDF::Type::Signature::VerificationResult::Message.new(:warning, 'c')
      error = HexaPDF::Type::Signature::VerificationResult::Message.new(:error, 'c')
      assert_equal([error, warning, info], [info, error, warning].sort)
    end
  end

  before do
    @result = HexaPDF::Type::Signature::VerificationResult.new
  end

  it "can add new messages" do
    @result.log(:error, "content")
    assert_equal(1, @result.messages.size)
    assert_equal(:error, @result.messages[0].type)
    assert_equal('content', @result.messages[0].content)
  end

  it "reports success if no error messages have been logged" do
    assert(@result.success?)
    @result.log(:info, 'content')
    assert(@result.success?)
    @result.log(:error, 'failure')
    refute(@result.success?)
  end

  it "reports failure if there is at least one error message" do
    @result.log(:info, 'content')
    refute(@result.failure?)
    @result.log(:error, 'failure')
    assert(@result.failure?)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
hexapdf-0.28.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.27.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.26.2 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.26.1 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.26.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.25.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.24.2 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.24.1 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.24.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.23.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.22.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.21.1 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.21.0 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.20.4 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.20.3 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.20.2 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.20.1 test/hexapdf/type/signature/test_verification_result.rb
hexapdf-0.20.0 test/hexapdf/type/signature/test_verification_result.rb