mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
improved some example descriptions
This commit is contained in:
parent
79460dc39b
commit
9e689746f3
@ -48,11 +48,11 @@ describe ValidatesTimeliness::Formats do
|
||||
end
|
||||
|
||||
describe "format proc generator" do
|
||||
it "should generate proc which outputs date array" do
|
||||
it "should generate proc which outputs date array with values in correct order" do
|
||||
generate_proc('yyyy-mm-dd').call('2000', '1', '2').should == [2000,1,2,0,0,0,0]
|
||||
end
|
||||
|
||||
it "should generate proc which outputs date array from format in non time array order" do
|
||||
it "should generate proc which outputs date array from format with different order" do
|
||||
generate_proc('dd/mm/yyyy').call('2', '1', '2000').should == [2000,1,2,0,0,0,0]
|
||||
end
|
||||
|
||||
|
||||
@ -1 +0,0 @@
|
||||
Subproject commit 7d4e697b1cee90bb1f34ac302881ce0641e654ec
|
||||
20
spec/time_travel/MIT-LICENSE
Normal file
20
spec/time_travel/MIT-LICENSE
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) 2008 Peter Yandell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
33
spec/time_travel/time_extensions.rb
Normal file
33
spec/time_travel/time_extensions.rb
Normal file
@ -0,0 +1,33 @@
|
||||
require 'time'
|
||||
|
||||
module TimeTravel
|
||||
module TimeExtensions
|
||||
|
||||
def self.included(base)
|
||||
base.extend(ClassMethods)
|
||||
base.class_eval do
|
||||
class << self
|
||||
alias_method :immutable_now, :now
|
||||
alias_method :now, :mutable_now
|
||||
end
|
||||
end
|
||||
base.now = nil
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
@@now = nil
|
||||
|
||||
def now=(time)
|
||||
time = Time.parse(time) if time.instance_of?(String)
|
||||
@@now = time
|
||||
end
|
||||
|
||||
def mutable_now #:nodoc:
|
||||
@@now || immutable_now
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
12
spec/time_travel/time_travel.rb
Normal file
12
spec/time_travel/time_travel.rb
Normal file
@ -0,0 +1,12 @@
|
||||
require 'time_travel/time_extensions'
|
||||
|
||||
Time.send(:include, TimeTravel::TimeExtensions)
|
||||
|
||||
def at_time(time)
|
||||
Time.now = time
|
||||
begin
|
||||
yield
|
||||
ensure
|
||||
Time.now = nil
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user