Class: Specificator::Expectation::Association
- Inherits:
-
Object
- Object
- Specificator::Expectation::Association
- Defined in:
- lib/specificator/expectation/association.rb
Constant Summary collapse
- ASSOCIATIONS_MAPPING =
{ has_many: :have_many, belongs_to: :belong_to, has_one: :have_one, has_and_belongs_to_many: :have_and_belong_to_many }
- OPTIONS_MAPPING =
{ class_name: :class_name, primary_key: :with_primary_key, foreign_key: :with_foreign_key, dependent: :dependent, counter_cache: :counter_cache, optional: :optional }
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(association) ⇒ Association
constructor
A new instance of Association.
- #valid? ⇒ Boolean
Constructor Details
#initialize(association) ⇒ Association
Returns a new instance of Association.
26 27 28 |
# File 'lib/specificator/expectation/association.rb', line 26 def initialize(association) @association = association end |
Instance Attribute Details
#association ⇒ Object
Returns the value of attribute association.
20 21 22 |
# File 'lib/specificator/expectation/association.rb', line 20 def association @association end |
Class Method Details
.for(association) ⇒ Object
22 23 24 |
# File 'lib/specificator/expectation/association.rb', line 22 def self.for(association) new(association).call end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 |
# File 'lib/specificator/expectation/association.rb', line 30 def call return unless valid? "it { should #{expectation} } #{Specificator::Generator::WATERMARK}" end |
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/specificator/expectation/association.rb', line 36 def valid? association_type.present? end |