Skip to content

Commit

Permalink
Added validates_numericality_of
Browse files Browse the repository at this point in the history
  • Loading branch information
postpostmodern committed Sep 9, 2008
1 parent cfda850 commit da0d817
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/spec/rails/matchers/validations.rb
Expand Up @@ -8,6 +8,13 @@ def validate_presence_of(attribute)
end end
end end


def validate_numericality_of(attribute)
return simple_matcher("validate the numericality of #{attribute}") do |model|
model.send("#{attribute}=", 'foo')
!model.valid? && model.errors.invalid?(attribute)
end
end

def validate_length_of(attribute, options) def validate_length_of(attribute, options)
if options.has_key? :within if options.has_key? :within
min = options[:within].first min = options[:within].first
Expand Down

0 comments on commit da0d817

Please sign in to comment.