Sha256: c700d7e3e9ec61bee212ac609d536ebd99056b39e5c7388d85515f49a92c871f
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require "test_helper" class ValidatesSshPrivateKeyCommonTest < Minitest::Test let(:model) do Class.new do def self.name "User" end include ActiveModel::Model validates_ssh_private_key :key attr_accessor :key end end test "fails when sshkey is not available" do assert_raises(StandardError, /sshkey is not part of the bundle/) do Class.new do Validators.expects(:require).with("sshkey").raises(LoadError.new("-- sshkey")) include ActiveModel::Model validates_ssh_private_key :key end end end test "requires valid key" do record = model.new(key: "invalid") record.valid? refute record.errors[:key].empty? end test "accepts valid key" do record = model.new(key: SSHKey.generate.private_key) record.valid? assert record.errors[:key].empty? end test "sets translated error message" do I18n.locale = "pt-BR" message = "não é uma chave privada de SSH válida" record = model.new(key: "invalid") record.valid? assert_includes record.errors[:key], message end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
validators-3.4.2 | test/validators/validates_ssh_private_key/common_test.rb |
validators-3.4.1 | test/validators/validates_ssh_private_key/common_test.rb |