Sha256: fb1cefd3d3c4388113e8b91102d4f5600c95c92926d9ac8af3836b7f6f638536

Contents?: true

Size: 889 Bytes

Versions: 4

Compression:

Stored size: 889 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Attribute, '#valid_value?' do
  subject { object.valid_value?(value) }

  let(:described_class) { Attribute::Integer }

  context 'when value is nil' do
    let(:value) { nil }

    context 'and the attribute is required' do
      let(:object) { described_class.new(:id) }

      it { should be(false) }
    end

    context 'and the attribute not required' do
      let(:object) { described_class.new(:id, :required => false) }

      it { should be(true) }
    end
  end

  context 'when the value is a valid primitive' do
    let(:object) { described_class.new(:id) }
    let(:value)  { 1                        }

    it { should be(true) }
  end

  context 'when the value is not a valid primitive' do
    let(:object) { described_class.new(:id) }
    let(:value)  { 'a'                      }

    it { should be(false) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/attribute/valid_value_spec.rb
veritas-0.0.6 spec/unit/veritas/attribute/valid_value_spec.rb
veritas-0.0.5 spec/unit/veritas/attribute/valid_value_spec.rb
veritas-0.0.4 spec/unit/veritas/attribute/valid_value_spec.rb