diff --git a/lib/validates_timeliness/helper_methods.rb b/lib/validates_timeliness/helper_methods.rb index bea4ed6..c208300 100644 --- a/lib/validates_timeliness/helper_methods.rb +++ b/lib/validates_timeliness/helper_methods.rb @@ -2,7 +2,12 @@ module ValidatesTimeliness module HelperMethods extend ActiveSupport::Concern - module ClassMethods + included do + include ValidationMethods + extend ValidationMethods + end + + module ValidationMethods def validates_date(*attr_names) validates_with Validator, _merge_attributes(attr_names).merge(:type => :date) end diff --git a/spec/validates_timeliness/helper_methods_spec.rb b/spec/validates_timeliness/helper_methods_spec.rb new file mode 100644 index 0000000..bc480a4 --- /dev/null +++ b/spec/validates_timeliness/helper_methods_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe ValidatesTimeliness::HelperMethods do + it 'should define class validation methods on extended classes' do + ActiveRecord::Base.should respond_to(:validates_date) + ActiveRecord::Base.should respond_to(:validates_time) + ActiveRecord::Base.should respond_to(:validates_datetime) + end + + it 'should define instance validation methods on extended classes' do + ActiveRecord::Base.instance_methods.should include('validates_date') + ActiveRecord::Base.instance_methods.should include('validates_time') + ActiveRecord::Base.instance_methods.should include('validates_datetime') + end +end