Class: Shoulda::Matchers::ActiveRecord::AssociationMatchers::SourceMatcher
- Inherits:
-
Object
- Object
- Shoulda::Matchers::ActiveRecord::AssociationMatchers::SourceMatcher
- Defined in:
- lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb
Instance Attribute Summary collapse
-
#missing_option ⇒ Object
Returns the value of attribute missing_option.
Instance Method Summary collapse
- #description ⇒ Object
-
#initialize(source, name) ⇒ SourceMatcher
constructor
A new instance of SourceMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(source, name) ⇒ SourceMatcher
Returns a new instance of SourceMatcher.
9 10 11 12 13 |
# File 'lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb', line 9 def initialize(source, name) @source = source @name = name @missing_option = '' end |
Instance Attribute Details
#missing_option ⇒ Object
Returns the value of attribute missing_option.
7 8 9 |
# File 'lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb', line 7 def missing_option @missing_option end |
Instance Method Details
#description ⇒ Object
15 16 17 |
# File 'lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb', line 15 def description "source => #{source}" end |
#matches?(subject) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb', line 19 def matches?(subject) self.subject = ModelReflector.new(subject, name) if option_verifier.correct_for_string?(:source, source) true else self.missing_option = "#{name} should have #{source} as source option" false end end |