Sha256: f2fd0e6e44104a3e61dd2e98cfcc4e7705c752fa15b9f23ff63d69b54bf09205

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

##
# Allows testing of multiple columns in a database for a single trait
#
module SpecStacker

	##
	#it should test value for action
	#+value+:: symbol for a column name
	#+action+:: symbol for an action (eg. +validate_presence_of+)
	def it_should value, action
		it { should send(action, value) }
	end

	##
	#test attributes with action
	#+attributes+:: array of symbols of columns names
	#+action+:: the action to check, see it_should
	def should_all attributes, action
		attributes.each { |k| it_should(k, action) }
	end

	##
	#test if attributes are present
	#+attributes+:: array of symbols of column names
	def should_all_be_present attributes
		should_all attributes, :validate_presence_of
	end

	##
	#test if all attributes have_and_belong_to_many
	#+value+:: symbol of column name
	#
	#the normal identifier is too long.
	def should_all_join attributes
		should_all attributes, :have_and_belong_to_many
	end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_model_stacker-0.0.3 lib/rails_model_stacker/spec_stacker.rb