class Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher
@private
Attributes
error[R]
rich_text_attribute[R]
subject[R]
Public Class Methods
new(rich_text_attribute)
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 31 def initialize(rich_text_attribute) @rich_text_attribute = rich_text_attribute end
Public Instance Methods
description()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 35 def description "have configured :#{rich_text_attribute} as a "\ 'ActionText::RichText association' end
failure_message()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 40 def failure_message "Expected #{subject.class} to #{error_description}" end
failure_message_when_negated()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 44 def failure_message_when_negated "Did not expect #{subject.class} to have ActionText::RichText"\ " :#{rich_text_attribute}" end
matches?(subject)
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 49 def matches?(subject) @subject = subject @error = run_checks @error.nil? end
Private Instance Methods
error_description()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 77 def error_description error == :default ? description : "#{description} but #{error}" end
has_attribute?()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 67 def has_attribute? @subject.respond_to?(rich_text_attribute.to_s) end
has_expected_action_text?()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 71 def has_expected_action_text? defined?(ActionText::RichText) && @subject.send(rich_text_attribute). instance_of?(ActionText::RichText) end
run_checks()
click to toggle source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 59 def run_checks if !has_attribute? ":#{rich_text_attribute} does not exist" elsif !has_expected_action_text? :default end end