Class: Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher
- Defined in:
- lib/shoulda/matchers/active_record/have_attached_matcher.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
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.
58 59 60 61 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 58 def initialize(macro, name) @macro = macro @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
56 57 58 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 56 def name @name end |
Instance Method Details
#description ⇒ Object
63 64 65 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 63 def description "have a has_#{macro}_attached called #{name}" end |
#expectation ⇒ Object
80 81 82 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 80 def expectation "#{model_class.name} to #{description}" end |
#failure_message ⇒ Object
67 68 69 70 71 72 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 67 def "Expected \#{expectation}, but this could not be proved.\n \#{@failure}\n MESSAGE\nend\n" |
#failure_message_when_negated ⇒ Object
74 75 76 77 78 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 74 def "Did not expect \#{expectation}, but it does.\n MESSAGE\nend\n" |
#matches?(subject) ⇒ Boolean
84 85 86 87 88 89 90 91 |
# File 'lib/shoulda/matchers/active_record/have_attached_matcher.rb', line 84 def matches?(subject) @subject = subject reader_attribute_exists? && writer_attribute_exists? && && blobs_association_exists? && eager_loading_scope_exists? end |