spec/support/activemodel_helpers.rb in shoulda-matchers-2.6.1.rc1 vs spec/support/activemodel_helpers.rb in shoulda-matchers-2.6.1.rc2

- old
+ new

@@ -1,12 +1,16 @@ module ActiveModelHelpers - def custom_validation(&block) - define_model(:example, attr: :integer) do + def custom_validation(options = {}, &block) + attribute_name = options.fetch(:attribute_name, :attr) + attribute_type = options.fetch(:attribute_type, :integer) + + define_model(:example, attribute_name => attribute_type) do validate :custom_validation define_method(:custom_validation, &block) end.new end + alias record_with_custom_validation custom_validation def validating_format(options) define_model :example, attr: :string do validates_format_of :attr, options end.new