Sha256: 9de3d33887592596fd7a2d65784fbb10196faeaa641ad641184074f299f44e57

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'
require 'unit/contextual_validators/spec_helper'

describe 'DataMapper::Validations::ContextualValidators' do
  before :all do
    @model = DataMapper::Validations::ContextualValidators.new
  end

  describe "initially" do
    it "is empty" do
      @model.should be_empty
    end
  end


  describe "after first reference to context" do
    before :all do
      @model.context(:create)
    end

    it "initializes list of validators for referred context" do
      @model.context(:create).should be_empty
    end
  end


  describe "after a context being added" do
    before :all do
      @model.context(:default) << DataMapper::Validations::PresenceValidator.new(:toc, :when => [:publishing])
    end

    it "is no longer empty" do
      @model.should_not be_empty
    end
  end


  describe "when cleared" do
    before :all do
      @model.context(:default) << DataMapper::Validations::PresenceValidator.new(:toc, :when => [:publishing])
      @model.should_not be_empty
      @model.clear!
    end

    it "becomes empty again" do
      @model.should be_empty
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
dm-validations-1.1.0 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.1.0.rc3 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.1.0.rc2 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.1.0.rc1 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.2 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.1 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.0 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.0.rc3 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.0.rc2 spec/unit/contextual_validators/emptiness_spec.rb
dm-validations-1.0.0.rc1 spec/unit/contextual_validators/emptiness_spec.rb