class Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher
@private
Attributes
Public Class Methods
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
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
Source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 40 def failure_message "Expected #{subject.class} to #{error_description}" end
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
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
Source
# File lib/shoulda/matchers/active_record/have_rich_text_matcher.rb, line 77 def error_description error == :default ? description : "#{description} but #{error}" end
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
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
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