From 4f421d87fc0f0e60c6aa532d7ec4160ff54a90fe Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Mon, 18 Oct 2010 11:15:50 +1100 Subject: [PATCH] add remove_use_formats alias to Timeliness and spec config spec --- lib/validates_timeliness.rb | 1 + spec/validates_timeliness_spec.rb | 43 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 spec/validates_timeliness_spec.rb diff --git a/lib/validates_timeliness.rb b/lib/validates_timeliness.rb index 8682dd7..6e17831 100644 --- a/lib/validates_timeliness.rb +++ b/lib/validates_timeliness.rb @@ -15,6 +15,7 @@ Timeliness.module_eval do class << self alias :dummy_date_for_time_type :date_for_time_type alias :dummy_date_for_time_type= :date_for_time_type= + alias :remove_us_formats :use_euro_formats end end diff --git a/spec/validates_timeliness_spec.rb b/spec/validates_timeliness_spec.rb new file mode 100644 index 0000000..7a68650 --- /dev/null +++ b/spec/validates_timeliness_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe ValidatesTimeliness do + + it 'should alias use_euro_formats to remove_us_formats on Timeliness gem' do + Timeliness.should respond_to(:remove_us_formats) + end + + it 'should alias to date_for_time_type to dummy_date_for_time_type on Timeliness gem' do + Timeliness.should respond_to(:dummy_date_for_time_type) + end + + describe "config" do + it 'should delegate default_timezone to Timeliness gem' do + Timeliness.should_receive(:default_timezone=) + ValidatesTimeliness.default_timezone = :utc + end + + it 'should delegate dummy_date_for_time_type to Timeliness gem' do + Timeliness.should_receive(:dummy_date_for_time_type) + Timeliness.should_receive(:dummy_date_for_time_type=) + array = ValidatesTimeliness.dummy_date_for_time_type + ValidatesTimeliness.dummy_date_for_time_type = array + end + + context "parser" do + it 'should delegate add_formats to Timeliness gem' do + Timeliness.should_receive(:add_formats) + ValidatesTimeliness.parser.add_formats + end + + it 'should delegate remove_formats to Timeliness gem' do + Timeliness.should_receive(:remove_formats) + ValidatesTimeliness.parser.remove_formats + end + + it 'should delegate remove_us_formats to Timeliness gem' do + Timeliness.should_receive(:remove_us_formats) + ValidatesTimeliness.parser.remove_us_formats + end + end + end +end