class Shoulda::Matchers::ActiveRecord::HaveImplicitOrderColumnMatcher
@private
Attributes
Public Class Methods
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 33 def initialize(column_name) @column_name = column_name end
Public Instance Methods
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 61 def description expectation end
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 55 def failure_message_when_negated Shoulda::Matchers.word_wrap( "Expected #{model.name} not to #{expectation}, but it did.", ) end
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 37 def matches?(subject) @subject = subject check_column_exists! check_implicit_order_column_matches! true rescue SecondaryCheckFailedError => e @failure_message = Shoulda::Matchers.word_wrap( "Expected #{model.name} to #{expectation}, " + "but that could not be proved: #{e.message}.", ) false rescue PrimaryCheckFailedError => e @failure_message = Shoulda::Matchers.word_wrap( "Expected #{model.name} to #{expectation}, but #{e.message}.", ) false end
Private Instance Methods
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 69 def check_column_exists! matcher = HaveDbColumnMatcher.new(column_name) if !matcher.matches?(@subject) raise SecondaryCheckFailedError.new( "The :#{model.table_name} table does not have a " + ":#{column_name} column", ) end end
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 80 def check_implicit_order_column_matches! if model.implicit_order_column.to_s != column_name.to_s message = if model.implicit_order_column.nil? 'implicit_order_column is not set' else "it is :#{model.implicit_order_column}" end raise PrimaryCheckFailedError.new(message) end end
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 97 def expectation "have an implicit_order_column of :#{column_name}" end
Source
# File lib/shoulda/matchers/active_record/have_implicit_order_column.rb, line 93 def model subject.class end