module OMU::Support::Minitest::AssociationHelper

Constants

RELATIONS
SUFFIX

Public Instance Methods

accepts_nested_attributes_for(attribute, **options) click to toggle source
# File lib/omu_support/minitest/association_helper.rb, line 23
def accepts_nested_attributes_for(attribute, **options)
  nested_attributes_options = klass.nested_attributes_options[attribute]

  test "#{attribute} must be nested attribute" do
    assert nested_attributes_options
    options.each do |key, value|
      assert_equal nested_attributes_options[key], value, "Option: #{key}"
    end
  end
end

Private Instance Methods

klass() click to toggle source
# File lib/omu_support/minitest/association_helper.rb, line 42
def klass
  to_s.delete_suffix(SUFFIX).constantize
end
relations_for(relation, attribute) click to toggle source
# File lib/omu_support/minitest/association_helper.rb, line 36
def relations_for(relation, attribute)
  klass.reflect_on_all_associations(relation).find do |association|
    association.name == attribute
  end
end