add class to wrap sensitive values

This commit is contained in:
2025-03-09 15:30:33 -05:00
parent cca1aa4604
commit aa907dfa5f
3 changed files with 91 additions and 0 deletions

26
spec/sensitive_spec.rb Normal file
View File

@ -0,0 +1,26 @@
require "minitest/autorun"
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
require "sensitive"
ALPHABET = ('a' .. 'z').reduce(:concat)
describe "Sensitive" do
before do
@s = Sensitive.new ALPHABET
end
it "test initialize" do
_(@s.to_s).must_equal "ab" + "*" * 22 + "yz"
end
it "test initialize" do
_(@s.unwrap).must_equal ALPHABET
end
it "test using different mask character" do
s = Sensitive.new ALPHABET, ch: "x"
_(s.to_s).must_equal "x"
end
end