class Shoulda::ActiveRecord::Matchers::AllowMassAssignmentOfMatcher

:nodoc:

def accessible_attributes

def accessible_attributes
  @accessible_attributes ||= (@subject.class.accessible_attributes || [])
end

def attr_mass_assignable?

def attr_mass_assignable?
  if whitelisting?
    accessible_attributes.include?(@attribute)
  else
    !protected_attributes.include?(@attribute)
  end
end

def class_name

def class_name
  @subject.class.name
end

def description

def description
  "allow mass assignment of #{@attribute}"
end

def initialize(attribute)

def initialize(attribute)
  @attribute = attribute.to_s
end

def matches?(subject)

def matches?(subject)
  @subject = subject
  if attr_mass_assignable?
    if whitelisting?
      @failure_message = "#{@attribute} was made accessible"
    else
      if protected_attributes.empty?
        @failure_message = "no attributes were protected"
      else
        @failure_message = "#{class_name} is protecting " <<
          "#{protected_attributes.to_a.to_sentence}, " <<
          "but not #{@attribute}."
      end
    end
    true
  else
    if whitelisting?
      @negative_failure_message =
        "Expected #{@attribute} to be accessible"
    else
      @negative_failure_message =
        "Did not expect #{@attribute} to be protected"
    end
    false
  end
end

def protected_attributes

def protected_attributes
  @protected_attributes ||= (@subject.class.protected_attributes || [])
end

def whitelisting?

def whitelisting?
  !accessible_attributes.empty?
end