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

Version Path
active_validation-1.0.0 spec/lib/boolean_validator_spec.rb
yukonisuru-1.0.0 spec/lib/boolean_validator_spec.rb
yukonisuru-0.0.1 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.12 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.11 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.10 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.9 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.8 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.7 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.6 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.5 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.4 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.3 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.2 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.1 spec/lib/boolean_validator_spec.rb
flash_validators-3.0.0 spec/lib/boolean_validator_spec.rb
flash_validators-1.1.0 spec/lib/boolean_validator_spec.rb