spec/fixtures/barcode.rb in dm-validations-0.10.2 vs spec/fixtures/barcode.rb in dm-validations-1.0.0.rc1
- old
+ new
@@ -1,9 +1,10 @@
module DataMapper
- module Validate
+ module Validations
module Fixtures
class Barcode
+ attr_accessor :valid_hook_call_count
#
# Behaviors
#
@@ -19,14 +20,21 @@
#
# Validations
#
- validates_length :code, :max => 10
+ validates_length_of :code, :max => 10
def self.valid_instance
new(:code => "3600029145")
end
+
+ # measure the number of times #valid? is executed
+ before :valid? do
+ @valid_hook_call_count ||= 0
+ @valid_hook_call_count += 1
+ end
+
end # Barcode
end
end
end