Class: Shoulda::ActiveRecord::Matchers::HaveDbIndexMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActiveRecord::Matchers::HaveDbIndexMatcher
- Defined in:
- lib/shoulda/active_record/matchers/have_db_index_matcher.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(macro, columns) ⇒ HaveDbIndexMatcher
constructor
A new instance of HaveDbIndexMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #unique(unique) ⇒ Object
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
#description ⇒ Object
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_message ⇒ Object
41 42 43 |
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 41 def "Expected #{expectation} (#{@missing})" end |
#matches?(subject) ⇒ 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_message ⇒ Object
45 46 47 |
# File 'lib/shoulda/active_record/matchers/have_db_index_matcher.rb', line 45 def "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 |