class Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher

:nodoc:

def class_name

def class_name
  @subject.class.name
end

def description

def description
  "make #{@attribute} read-only"
end

def initialize(attribute)

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

def matches?(subject)

def matches?(subject)
  @subject = subject
  if readonly_attributes.include?(@attribute)
    @failure_message_when_negated = "Did not expect #{@attribute} to be read-only"
    true
  else
    if readonly_attributes.empty?
      @failure_message = "#{class_name} attribute #{@attribute} " <<
        'is not read-only'
    else
      @failure_message = "#{class_name} is making " <<
        "#{readonly_attributes.to_a.to_sentence} " <<
        "read-only, but not #{@attribute}."
    end
    false
  end
end

def readonly_attributes

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