Sha256: 6be461f8caf14e6af56543ca2ffdf2e85e66825320c54a648fbd2e917b474bb0

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env ruby

BEGIN {
	require 'pathname'
	basedir = Pathname.new( __FILE__ ).dirname.parent.parent.parent

	libdir = basedir + "lib"

	$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
	$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
}

require 'rspec'

require 'spec/lib/helpers'

require 'treequel/model'
require 'treequel/model/errors'
require 'treequel/branchset'



#####################################################################
###	C O N T E X T S
#####################################################################

describe Treequel::Model::Errors do

	before( :all ) do
		setup_logging( :fatal )
	end

	before( :each ) do
		@errors = Treequel::Model::Errors.new
	end

	after( :all ) do
		reset_logging()
	end


	it "allows the addition of errors" do
		@errors.add( :cn, "Not a common name." )
		@errors[:cn].should have( 1 ).member
		@errors[:cn].should include( "Not a common name." )
	end

	it "knows how many errors there are" do
		@errors.add( :l, "is not valid" )
		@errors.add( :description, "must be this tall to ride" )
		@errors.add( :description, "must have at least one value" )

		@errors.count.should == 3
	end

	it "is empty if there haven't been any errors registered" do
		@errors.should be_empty()
	end

	it "isn't empty if there have been errors registered" do
		@errors.add( :uid, 'duplicate value' )
		@errors.should_not be_empty()
	end

	it "can build an array of error messages" do
		@errors.add( :l, "is not a valid location" )
		@errors.add( [:givenName, :sn, :displayName], "must be unique" )

		@errors.full_messages.should have( 2 ).members
		@errors.full_messages.should include( "givenName and sn and displayName must be unique" )
		@errors.full_messages.should include( "l is not a valid location" )
	end

end


# vim: set nosta noet ts=4 sw=4:

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
treequel-1.11.0 spec/treequel/model/errors_spec.rb
treequel-1.10.0 spec/treequel/model/errors_spec.rb
treequel-1.9.1 spec/treequel/model/errors_spec.rb
treequel-1.9.0 spec/treequel/model/errors_spec.rb
treequel-1.8.6 spec/treequel/model/errors_spec.rb
treequel-1.8.5 spec/treequel/model/errors_spec.rb
treequel-1.8.4 spec/treequel/model/errors_spec.rb
treequel-1.8.3 spec/treequel/model/errors_spec.rb
treequel-1.8.3.pre546 spec/treequel/model/errors_spec.rb
treequel-1.8.3.pre545 spec/treequel/model/errors_spec.rb
treequel-1.8.2 spec/treequel/model/errors_spec.rb
treequel-1.8.1 spec/treequel/model/errors_spec.rb
treequel-1.8.0 spec/treequel/model/errors_spec.rb
treequel-1.7.2 spec/treequel/model/errors_spec.rb
treequel-1.7.1 spec/treequel/model/errors_spec.rb
treequel-1.7.0 spec/treequel/model/errors_spec.rb
treequel-1.6.0 spec/treequel/model/errors_spec.rb
treequel-1.5.3 spec/treequel/model/errors_spec.rb
treequel-1.5.2 spec/treequel/model/errors_spec.rb
treequel-1.5.1 spec/treequel/model/errors_spec.rb