Sha256: 06084d61df8a6326e172f9999709d8d755695f4daae5345ccb71cd945e861c2d

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe Spectifly::Base::EntityNode do
  describe 'uniqueness restriction' do
    it 'unique should be false by default and there should be no unique restriction' do
      field = described_class.new("Mini me")
      field.should_not be_unique
      field.restrictions.keys.should_not be_include('unique')
    end

    it 'adds a restriction and returns true for unique? if there is a uniqueness validation' do
      field = described_class.new("Little Snowflake", {"Validations" => "must be unique"})
      field.should be_unique
      field.restrictions.keys.include?('unique').should be_true
    end

    it 'adds a restriction and returns true for unique? if there is an attribute Unique set to true' do
      field = described_class.new("Little Snowflake", {"Unique" => "true"})
      field.should be_unique
      field.restrictions.keys.include?('unique').should be_true
    end

    it 'throws an error if the two ways of setting uniqueness contradict each other' do
      lambda {
      field = described_class.new("Little Snowflake?", {"Validations" => "must be unique", "Unique" => false})
      }.should raise_error
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spectifly-0.0.10 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.9 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.8 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.7 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.6 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.5 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.4 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.3 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.2 spec/spectifly/base/entity_node_spec.rb
spectifly-0.0.1 spec/spectifly/base/entity_node_spec.rb