Class: Shoulda::ActiveRecord::Matchers::AssociationMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActiveRecord::Matchers::AssociationMatcher
- Defined in:
- lib/shoulda/active_record/matchers/association_matcher.rb
Overview
:nodoc:
Instance Method Summary collapse
- #dependent(dependent) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(macro, name) ⇒ AssociationMatcher
constructor
A new instance of AssociationMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #through(through) ⇒ Object
Constructor Details
#initialize(macro, name) ⇒ AssociationMatcher
Returns a new instance of AssociationMatcher.
56 57 58 59 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 56 def initialize(macro, name) @macro = macro @name = name end |
Instance Method Details
#dependent(dependent) ⇒ Object
66 67 68 69 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 66 def dependent(dependent) @dependent = dependent self end |
#description ⇒ Object
89 90 91 92 93 94 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 89 def description description = "#{macro_description} #{@name}" description += " through #{@through}" if @through description += " dependent => #{@dependent}" if @dependent description end |
#failure_message ⇒ Object
81 82 83 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 81 def "Expected #{expectation} (#{@missing})" end |
#matches?(subject) ⇒ Boolean
71 72 73 74 75 76 77 78 79 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 71 def matches?(subject) @subject = subject association_exists? && macro_correct? && foreign_key_exists? && through_association_valid? && dependent_correct? && join_table_exists? end |
#negative_failure_message ⇒ Object
85 86 87 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 85 def "Did not expect #{expectation}" end |
#through(through) ⇒ Object
61 62 63 64 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 61 def through(through) @through = through self end |