more config hashes

This commit is contained in:
Gabe Berke-Williams 2012-04-24 17:00:26 -05:00
parent 7a6da9c82e
commit ed5b3ee269
2 changed files with 11 additions and 7 deletions

View File

@ -20,7 +20,9 @@ module Shoulda # :nodoc:
class ValidateAcceptanceOfMatcher < ValidationMatcher # :nodoc:
def with_message(message)
@expected_message = message if message
if message
@expected_message = message
end
self
end
@ -33,9 +35,7 @@ module Shoulda # :nodoc:
def description
"require #{@attribute} to be accepted"
end
end
end
end
end

View File

@ -18,9 +18,13 @@ module Shoulda # :nodoc:
end
class ValidateNumericalityOfMatcher < ValidationMatcher # :nodoc:
def initialize(attribute)
super(attribute)
@options = {}
end
def only_integer
@only_integer = true
@options[:only_integer] = true
self
end
@ -43,7 +47,7 @@ module Shoulda # :nodoc:
private
def allowed_type
if @only_integer
if @options[:only_integer]
"integer"
else
"numeric"
@ -51,9 +55,9 @@ module Shoulda # :nodoc:
end
def disallows_non_integers?
if @only_integer
if @options[:only_integer]
message = @expected_message || :not_an_integer
disallows_value_of(0.1, message) && disallows_value_of('0.1', message)
disallows_value_of(0.1, message)
else
true
end