class Shoulda::Matchers::ActiveRecord::AssociationMatchers::DependentMatcher

Attributes

dependent[RW]
missing_option[RW]
name[RW]

Public Class Methods

new(dependent, name) click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 8
def initialize(dependent, name)
  @dependent = dependent
  @name = name
  @missing_option = ''
end

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 14
def description
  "dependent => #{dependent}"
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb, line 18
def matches?(subject)
  subject = ModelReflector.new(subject, name)

  if dependent.nil? || subject.option_set_properly?(dependent, :dependent)
    true
  else
    self.missing_option = "#{name} should have #{dependent} dependency"
    false
  end
end