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
- #with_options(options) ⇒ Object
Constructor Details
#initialize(macro, name) ⇒ AssociationMatcher
Returns a new instance of AssociationMatcher.
64 65 66 67 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 64 def initialize(macro, name) @macro = macro @name = name end |
Instance Method Details
#dependent(dependent) ⇒ Object
74 75 76 77 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 74 def dependent(dependent) @dependent = dependent self end |
#description ⇒ Object
103 104 105 106 107 108 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 103 def description description = "#{macro_description} #{@name}" description += " through #{@through}" if @through description += " dependent => #{@dependent}" if @dependent description end |
#failure_message ⇒ Object
95 96 97 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 95 def "Expected #{expectation} (#{@missing})" end |
#matches?(subject) ⇒ Boolean
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 84 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
99 100 101 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 99 def "Did not expect #{expectation}" end |
#through(through) ⇒ Object
69 70 71 72 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 69 def through(through) @through = through self end |
#with_options(options) ⇒ Object
79 80 81 82 |
# File 'lib/shoulda/active_record/matchers/association_matcher.rb', line 79 def () @options = self end |