Sha256: 06de6b5c05847f5b78145fb5a642b273fba0d41c509d70520a5e13b96af06a76
Contents?: true
Size: 1.05 KB
Versions: 16
Compression:
Stored size: 1.05 KB
Contents
require 'spec_helper' describe Base64Validator do context "has a valid value" do let(:klass) do Class.new do include ActiveModel::Validations attr_accessor :code, :name validates :code, base64: true end end subject { klass.new } it { should allow_value("YW55IGNhcm5hbCBwbGVhcw==").for(:code) } it { should allow_value("YW55IGNhcm5hbCBwbGVhc3U=").for(:code) } it { should allow_value("YW55IGNhcm5hbCBwbGVhc3Vy").for(:code) } it { should allow_value("YW55IGNhcm5hbCBwbGVhc3VyZQ==").for(:code) } it { should allow_value("YW55IGNhcm5hbCBwbGVhc3VyZS4=").for(:code) } it { should_not allow_value('').for(:code) } it { should_not allow_value(' ').for(:code) } it { should_not allow_value(nil).for(:code) } it { should_not allow_value("1a.b2").for(:code) } it { should_not allow_value("1a b2").for(:code) } it { should_not allow_value("1a.b2==").for(:code) } it { should ensure_valid_base64_format_of(:code) } it { should_not ensure_valid_base64_format_of(:name) } end end
Version data entries
16 entries across 16 versions & 3 rubygems