Class: Shoulda::Matchers::ActiveRecord::HaveImplicitOrderColumnMatcher

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

Defined Under Namespace

Classes: PrimaryCheckFailedError, SecondaryCheckFailedError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_name) ⇒ HaveImplicitOrderColumnMatcher

Returns a new instance of HaveImplicitOrderColumnMatcher.



33
34
35
# File 'lib/shoulda/matchers/active_record/have_implicit_order_column.rb', line 33

def initialize(column_name)
  @column_name = column_name
end

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



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

def failure_message
  @failure_message
end

Instance Method Details

#descriptionObject



61
62
63
# File 'lib/shoulda/matchers/active_record/have_implicit_order_column.rb', line 61

def description
  expectation
end

#failure_message_when_negatedObject



55
56
57
58
59
# 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

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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