Skip to content

Commit

Permalink
validates_format_of is deprecated [#76 status:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 28, 2009
1 parent c95d060 commit cb57b2c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README
@@ -1,4 +1,4 @@
= Remarkable 3.0
= Remarkable

You can read this file nicely formatted at the Rubyforge project page:

Expand Down
3 changes: 3 additions & 0 deletions remarkable_activerecord/CHANGELOG
@@ -1,3 +1,6 @@
* Deprecated validate_format_of. It does not have the same API as the respective
ActiveRecord macro, raising questions frequentely about its usage. [#76]

* allow_mass_assignment_of when called without arguments checks if any mass
assignment is possible [#80]

Expand Down
5 changes: 3 additions & 2 deletions remarkable_activerecord/README
Expand Up @@ -3,8 +3,9 @@
Remarkable ActiveRecord is a collection of matchers to ActiveRecord. Why use
Remarkable?

* The only one with matchers for all ActiveRecord validations, with support to
all options (except :on and the option :with in validates_format_of);
* Matchers for all ActiveRecord validations, with support to all options. The only
exceptions are validate_format_of (which should be invoked as allow_values_for)
and the :on option;

* Matchers for all ActiveRecord associations. The only one which supports all
these options:
Expand Down
Expand Up @@ -87,7 +87,17 @@ def allow_values_for(attribute, *args, &block)
options = args.extract_options!
AllowValuesForMatcher.new(attribute, options.merge!(:in => args), &block).spec(self)
end
alias :validate_format_of :allow_values_for

# Deprecated. Use allow_values_for instead.
#
def validate_format_of(*args)
if caller[0] =~ /\macros.rb/
warn "[DEPRECATION] should_validate_format_of is deprecated, use should_allow_values_for instead."
else
warn "[DEPRECATION] validate_format_of is deprecated, use allow_values_for instead. Called from #{caller[0]}."
end
allow_values_for(*args)
end

end
end
Expand Down
5 changes: 5 additions & 0 deletions remarkable_activerecord/spec/allow_values_for_matcher_spec.rb
Expand Up @@ -51,6 +51,11 @@ def define_and_validate(options={})

should_allow_values_for :title, 'X'
should_not_allow_values_for :title, 'A'

describe 'deprecation' do
it { should validate_format_of(:title, 'X') }
should_not_validate_format_of :title, 'A'
end
end
end

0 comments on commit cb57b2c

Please sign in to comment.