module Shoulda::ActiveRecord::Macros
def should_have_indices(*columns)
should_have_index :ssn, :unique => true
should_have_index :age
should_have_indices :email, :name, [:commentable_type, :commentable_id]
Examples:
unique or not. Default = nil
constraint. Use nil if you don't care whether the index is
constraint. Use false to explicitly test for a non-unique
constraint. Use true to explicitly test for a unique
* :unique - whether or not the index has a unique
Options:
Also aliased to should_have_index for readability
Ensures that there are DB indices on the given columns or tuples of columns.
def should_have_indices(*columns) unique = get_options!(columns, :unique) klass = model_class columns.each do |column| matcher = have_index(column).unique(unique) should matcher.description do assert_accepts(matcher, klass.new) end end end