Sha256: bfed3e3fee23d40482153afe9b36ff37497e095cfe96b27d2998225128622bd9

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe 'DataMapper::Validations::ValidationErrors' do
  before :all do
    @model = DataMapper::Validations::ValidationErrors.new(Object.new)
  end

  describe "after first error being added" do
    before :all do
      @model.add(:property, "can't be valid, no way")
    end

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

    it "adds error message to list of errors for given property name" do
      @model.on(:property).should == ["can't be valid, no way"]
    end
  end


  describe "after second error being added" do
    before :all do
      @model.add(:property, "can't be valid, no way")
      @model.add(:property, "something else is wrong")
    end

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

    it "appends error message to list of errors for given property name" do
      @model.on(:property).should == ["can't be valid, no way", "something else is wrong"]
    end
  end


  describe "when duplicate error being added" do
    before :all do
      @model.add(:property, "can't be valid, no way")
      @model.add(:property, "can't be valid, no way")
    end

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

    it "DOES NOT allow duplication" do
      @model.on(:property).should == ["can't be valid, no way"]
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
ardm-validations-1.2.0 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.2.0 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.2.0.rc2 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.2.0.rc1 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.1.0 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.1.0.rc3 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.1.0.rc2 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.1.0.rc1 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.2 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.1 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.0 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.0.rc3 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.0.rc2 spec/unit/validation_errors/adding_spec.rb
dm-validations-1.0.0.rc1 spec/unit/validation_errors/adding_spec.rb