class Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher

@private

def description

def description
  "have configured :#{rich_text_attribute} as a "\
  'ActionText::RichText association'
end

def error_description

def error_description
  error == :default ? description : "#{description} but #{error}"
end

def failure_message

def failure_message
  "Expected #{subject.class} to #{error_description}"
end

def failure_message_when_negated

def failure_message_when_negated
  "Did not expect #{subject.class} to have ActionText::RichText"\
  " :#{rich_text_attribute}"
end

def has_attribute?

def has_attribute?
  @subject.respond_to?(rich_text_attribute.to_s)
end

def has_expected_action_text?

def has_expected_action_text?
  defined?(ActionText::RichText) &&
    @subject.send(rich_text_attribute).
      instance_of?(ActionText::RichText)
end

def initialize(rich_text_attribute)

def initialize(rich_text_attribute)
  @rich_text_attribute = rich_text_attribute
end

def matches?(subject)

def matches?(subject)
  @subject = subject
  @error = run_checks
  @error.nil?
end

def run_checks

def run_checks
  if !has_attribute?
    ":#{rich_text_attribute} does not exist"
  elsif !has_expected_action_text?
    :default
  end
end