Class: Remarkable::ActiveRecord::Matchers::AssociationMatcher
- Inherits:
-
Matcher::Base
- Object
- Matcher::Base
- Remarkable::ActiveRecord::Matchers::AssociationMatcher
- Defined in:
- lib/remarkable/active_record/macros/associations/association_matcher.rb
Instance Method Summary collapse
- #dependent(dependent) ⇒ Object
- #description ⇒ Object
- #failure_message ⇒ Object
-
#initialize(macro, *associations) ⇒ AssociationMatcher
constructor
A new instance of AssociationMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
- #through(through) ⇒ Object
Methods inherited from Matcher::Base
Methods included from Matcher::DSL
Constructor Details
#initialize(macro, *associations) ⇒ AssociationMatcher
Returns a new instance of AssociationMatcher.
6 7 8 9 10 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 6 def initialize(macro, *associations) @options = associations. @macro = macro @associations = associations end |
Instance Method Details
#dependent(dependent) ⇒ Object
17 18 19 20 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 17 def dependent(dependent) @options[:dependent] = dependent self end |
#description ⇒ Object
38 39 40 41 42 43 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 38 def description description = "#{macro_description} #{@associations.to_sentence}" description += " through #{@options[:through]}" if @options[:through] description += " dependent => #{@options[:dependent]}" if @options[:dependent] description end |
#failure_message ⇒ Object
30 31 32 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 30 def "Expected #{expectation} (#{@missing})" end |
#matches?(subject) ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 22 def matches?(subject) @subject = subject assert_matcher_for(@associations) do |association| association_correct?(association) end end |
#negative_failure_message ⇒ Object
34 35 36 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 34 def "Did not expect #{expectation}" end |
#through(through) ⇒ Object
12 13 14 15 |
# File 'lib/remarkable/active_record/macros/associations/association_matcher.rb', line 12 def through(through) @options[:through] = through self end |