diff --git a/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb b/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb index 8b583a4e3..a1dd3ef93 100644 --- a/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb +++ b/lib/shoulda/matchers/active_record/define_enum_for_matcher.rb @@ -619,11 +619,17 @@ def expected_default_value end def actual_default_value - attribute_schema = model.attributes_to_define_after_schema_loads[attribute_name.to_s] + attribute_schema = model.respond_to?(:_default_attributes) ? model._default_attributes[attribute_name.to_s] : model.attributes_to_define_after_schema_loads[attribute_name.to_s] + + if Kernel.const_defined?('ActiveModel::Attribute::UserProvidedDefault') && attribute_schema.is_a?(::ActiveModel::Attribute::UserProvidedDefault) + attribute_schema = attribute_schema.marshal_dump + end value = case attribute_schema in [_, { default: default_value } ] default_value + in [_, default_value, *] + default_value in [_, default_value] default_value end