Class: Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/matchers/active_record/have_rich_text_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(rich_text_attribute) ⇒ HaveRichTextMatcher

Returns a new instance of HaveRichTextMatcher.



31
32
33
# 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

Instance Method Details

#descriptionObject



35
36
37
38
# 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_messageObject



40
41
42
# 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_negatedObject



44
45
46
47
# 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) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
# File 'lib/shoulda/matchers/active_record/have_rich_text_matcher.rb', line 49

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