class Shoulda::Matchers::ActiveRecord::HaveImplicitOrderColumnMatcher
@private
def check_column_exists!
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
def check_implicit_order_column_matches!
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
def description
def description expectation end
def expectation
def expectation "have an implicit_order_column of :#{column_name}" end
def failure_message_when_negated
def failure_message_when_negated Shoulda::Matchers.word_wrap( "Expected #{model.name} not to #{expectation}, but it did.", ) end
def initialize(column_name)
def initialize(column_name) @column_name = column_name end
def matches?(subject)
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
def model
def model subject.class end