Class: Shoulda::ActiveRecord::Matchers::HaveDbIndexMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/active_record/matchers/have_db_index_matcher.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(macro, columns) ⇒ HaveDbIndexMatcher

Returns a new instance of HaveDbIndexMatcher.



26
27
28
29
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 26

def initialize(macro, columns)
  @macro = macro
  @columns = normalize_columns_to_array(columns)
end

Instance Method Details

#descriptionObject



49
50
51
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 49

def description
  "have a #{index_type} index on columns #{@columns.join(' and ')}"
end

#failure_messageObject



41
42
43
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 41

def failure_message
  "Expected #{expectation} (#{@missing})"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 36

def matches?(subject)
  @subject = subject
  index_exists? && correct_unique?
end

#negative_failure_messageObject



45
46
47
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 45

def negative_failure_message
  "Did not expect #{expectation}"
end

#unique(unique) ⇒ Object



31
32
33
34
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 31

def unique(unique)
  @unique = unique
  self
end