Sha256: 60c52b2b795a2c048f826c785beeff003998d80e4a530ddb948e4d37c3a908ae
Contents?: true
Size: 1.07 KB
Versions: 17
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' describe BooleanValidator do context "has a valid value" do let(:klass) do Class.new do include ActiveModel::Validations attr_accessor :active, :name validates :active, boolean: true end end subject { klass.new } it { should allow_value(true).for(:active) } it { should allow_value(false).for(:active) } it { should allow_value(1).for(:active) } it { should allow_value(0).for(:active) } it { should_not allow_value('').for(:active) } it { should_not allow_value(' ').for(:active) } it { should_not allow_value(nil).for(:active) } it { should_not allow_value("true").for(:active) } it { should_not allow_value("false").for(:active) } it { should_not allow_value("1").for(:active) } it { should_not allow_value("0").for(:active) } it { should_not allow_value("! \#$%\`|").for(:active) } it { should_not allow_value("<>@[]\`|").for(:active) } it { should ensure_valid_boolean_format_of(:active) } it { should_not ensure_valid_boolean_format_of(:name) } end end
Version data entries
17 entries across 17 versions & 3 rubygems