Parent

Class/Module Index [+]

Quicksearch

Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher

@private

Attributes

failure_message[R]
failure_message_for_should[R]
failure_message_for_should_not[R]
failure_message_when_negated[R]

Public Class Methods

new(attribute) click to toggle source
# File lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb, line 29
def initialize(attribute)
  @attribute = attribute.to_s
end

Public Instance Methods

description() click to toggle source
# File lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb, line 56
def description
  "make #{@attribute} read-only"
end
matches?(subject) click to toggle source
# File lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb, line 38
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.