Object
@private
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 99 def description if @options.key?(:unique) "have a #{index_type} index on columns #{@columns.join(' and ')}" else "have an index on columns #{@columns.join(' and ')}" end end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 89 def failure_message "Expected #{expectation} (#{@missing})" end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 94 def failure_message_when_negated "Did not expect #{expectation}" end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 113 def correct_unique? return true unless @options.key?(:unique) is_unique = matched_index.unique is_unique = !is_unique unless @options[:unique] unless is_unique @missing = "#{table_name} has an index named #{matched_index.name} " << "of unique #{matched_index.unique}, not #{@options[:unique]}." end is_unique end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 144 def expectation "#{model_class.name} to #{description}" end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 109 def index_exists? ! matched_index.nil? end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 148 def index_type if @options[:unique] 'unique' else 'non-unique' end end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 140 def indexes ::ActiveRecord::Base.connection.indexes(table_name) end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 128 def matched_index indexes.detect { |each| each.columns == @columns } end
# File lib/shoulda/matchers/active_record/have_db_index_matcher.rb, line 132 def model_class @subject.class end
Generated with the Darkfish Rdoc Generator 2.