Class: Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher
- Defined in:
- lib/shoulda/matchers/active_record/have_attached_matcher.rb
Constant Summary collapse
- OPTION_METHODS =
{ service: -> (value) { value }, strict_loading: -> (value = true) { value }, dependent: -> (value) { value }, }.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #description ⇒ Object
- #expectation ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(macro, name) ⇒ HaveAttachedMatcher
constructor
A new instance of HaveAttachedMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(macro, name) ⇒ HaveAttachedMatcher
Returns a new instance of HaveAttachedMatcher.
126 127 128 129 130 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 126 def initialize(macro, name) @macro = macro @name = name = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
124 125 126 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 124 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
124 125 126 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 124 def end |
Instance Method Details
#description ⇒ Object
132 133 134 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 132 def description "have a has_#{macro}_attached called #{name}" end |
#expectation ⇒ Object
149 150 151 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 149 def expectation "#{model_class.name} to #{description}" + build_expectation_suffix end |
#failure_message ⇒ Object
136 137 138 139 140 141 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 136 def "Expected \#{expectation}, but this could not be proved.\n \#{@failure}\n MESSAGE\nend\n" |
#failure_message_when_negated ⇒ Object
143 144 145 146 147 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 143 def "Did not expect \#{expectation}, but it does.\n MESSAGE\nend\n" |
#matches?(subject) ⇒ Boolean
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 153 def matches?(subject) @subject = subject reader_attribute_exists? && writer_attribute_exists? && && blobs_association_exists? && eager_loading_scope_exists? && service_correct? && dependent_option_correct? end |