Sha256: d223318800876fa05f2a2af0b88613ab36d39c006f1d15f04111088054533596

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# -*- coding: utf-8 -*-
require_relative '../../spec_helper'
require_relative 'spec_helper'

describe 'DataMapper::Validations::ContextualRuleSet' do
  before :all do
    @validators = DataMapper::Validations::ContextualRuleSet.new
  end

  describe "initially" do
    it "is empty" do
      expect(@validators).to be_empty
    end
  end


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

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


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

    it "is no longer empty" do
      expect(@validators).not_to be_empty
    end
  end


  describe "when cleared" do
    before :all do
      @validators.context(:default) << DataMapper::Validations::Rule::Presence.new(:toc, :when => [:publishing])
      expect(@validators).not_to be_empty
      @validators.clear
    end

    it "becomes empty again" do
      expect(@validators).to be_empty
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sbf-dm-validations-1.4.0 spec/unit/contextual_validators/emptiness_spec.rb
sbf-dm-validations-1.3.0 spec/unit/contextual_validators/emptiness_spec.rb
sbf-dm-validations-1.3.0.beta spec/unit/contextual_validators/emptiness_spec.rb