Update to Timecop 0.7.1.

epel9
Vít Ondruch 11 years ago
parent f53485daa4
commit b4d9210a4a

1
.gitignore vendored

@ -1,2 +1,3 @@
/rubygem-timecop-failed-assert-fix.patch
/timecop-0.3.5.gem
/timecop-0.7.1.gem

@ -0,0 +1,253 @@
From c30897f67ad90f0582c0ed0d7b78f46a7142f113 Mon Sep 17 00:00:00 2001
From: Travis Jeffery <tj@travisjeffery.com>
Date: Sat, 10 May 2014 01:16:30 -0500
Subject: [PATCH] Use minitest
---
test/test_helper.rb | 6 ++--
test/time_stack_item_test.rb | 10 ++-----
test/timecop_test.rb | 40 +++++++++++--------------
test/timecop_without_date_but_with_time_test.rb | 10 ++---
test/timecop_without_date_test.rb | 8 ++---
5 files changed, 32 insertions(+), 42 deletions(-)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 2d7852e..e2b059a 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,14 +1,14 @@
require 'rubygems'
require 'bundler/setup'
-require 'test/unit'
+require 'minitest/autorun'
+
begin
require 'mocha/setup'
rescue LoadError
require 'mocha'
end
-class Test::Unit::TestCase
-
+class MiniTest::Unit::TestCase
private
# Tests to see that two times are within the given distance,
# in seconds, from each other.
diff --git a/test/time_stack_item_test.rb b/test/time_stack_item_test.rb
index f654fa1..3658127 100644
--- a/test/time_stack_item_test.rb
+++ b/test/time_stack_item_test.rb
@@ -4,7 +4,7 @@
require 'active_support/all'
-class TestTimeStackItem < Test::Unit::TestCase
+class TestTimeStackItem < MiniTest::Unit::TestCase
def teardown
Timecop.return
Time.zone = nil
@@ -204,16 +204,12 @@ def test_parse_only_string_with_active_support
end
def test_parse_date
- assert_nothing_raised do
- Timecop.freeze(Date.new(2012, 6, 9))
- end
+ Timecop.freeze(Date.new(2012, 6, 9))
end
def test_time_zone_returns_nil
Time.zone = nil
- assert_nothing_raised do
- Timecop.freeze
- end
+ Timecop.freeze
end
def test_nsecs_are_set
diff --git a/test/timecop_test.rb b/test/timecop_test.rb
index e954329..e5f7d79 100644
--- a/test/timecop_test.rb
+++ b/test/timecop_test.rb
@@ -2,7 +2,7 @@
require File.join(File.dirname(__FILE__), "test_helper")
require File.join(File.dirname(__FILE__), '..', 'lib', 'timecop')
-class TestTimecop < Test::Unit::TestCase
+class TestTimecop < MiniTest::Unit::TestCase
def teardown
Timecop.return
end
@@ -60,7 +60,7 @@ def test_travel_does_not_reduce_precision_of_datetime
# requires to_r on Float (>= 1.9)
if Float.method_defined?(:to_r)
Timecop.travel(1)
- assert_not_equal DateTime.now, DateTime.now
+ assert DateTime.now != DateTime.now
end
end
@@ -113,7 +113,7 @@ def test_recursive_freeze
end
assert_equal t, Time.now
end
- assert_not_equal t, Time.now
+ assert t != Time.now
end
def test_freeze_with_time_instance_works_as_expected
@@ -124,9 +124,9 @@ def test_freeze_with_time_instance_works_as_expected
assert_equal Date.new(2008, 10, 10), Date.today
end
- assert_not_equal t, Time.now
- assert_not_equal DateTime.new(2008, 10, 10, 10, 10, 10, local_offset), DateTime.now
- assert_not_equal Date.new(2008, 10, 10), Date.today
+ assert t != Time.now
+ assert DateTime.new(2008, 10, 10, 10, 10, 10, local_offset) != DateTime.now
+ assert Date.new(2008, 10, 10) != Date.today
end
def test_freeze_with_datetime_on_specific_timezone_during_dst
@@ -185,9 +185,9 @@ def test_freeze_with_date_instance_works_as_expected
assert_equal Time.local(2008, 10, 10, 0, 0, 0), Time.now
assert_date_times_equal DateTime.new(2008, 10, 10, 0, 0, 0, local_offset), DateTime.now
end
- assert_not_equal d, Date.today
- assert_not_equal Time.local(2008, 10, 10, 0, 0, 0), Time.now
- assert_not_equal DateTime.new(2008, 10, 10, 0, 0, 0, local_offset), DateTime.now
+ assert d != Date.today
+ assert Time.local(2008, 10, 10, 0, 0, 0) != Time.now
+ assert DateTime.new(2008, 10, 10, 0, 0, 0, local_offset) != DateTime.now
end
def test_freeze_with_integer_instance_works_as_expected
@@ -202,9 +202,9 @@ def test_freeze_with_integer_instance_works_as_expected
assert_equal Date.new(2008, 10, 10), Date.today
end
end
- assert_not_equal t, Time.now
- assert_not_equal DateTime.new(2008, 10, 10, 10, 10, 10), DateTime.now
- assert_not_equal Date.new(2008, 10, 10), Date.today
+ assert t != Time.now
+ assert DateTime.new(2008, 10, 10, 10, 10, 10) != DateTime.now
+ assert Date.new(2008, 10, 10) != Date.today
end
def test_exception_thrown_in_freeze_block_properly_resets_time
@@ -215,7 +215,7 @@ def test_exception_thrown_in_freeze_block_properly_resets_time
raise "blah exception"
end
rescue
- assert_not_equal t, Time.now
+ assert t != Time.now
assert_nil Time.send(:mock_time)
end
end
@@ -252,7 +252,7 @@ def test_mocked_date_time_now_is_local
if ENV['TZ'] == 'UTC'
assert_equal(local_offset, 0, "Local offset not be zero for #{ENV['TZ']}")
else
- assert_not_equal(local_offset, 0, "Local offset should not be zero for #{ENV['TZ']}")
+ assert(local_offset, 0 != "Local offset should not be zero for #{ENV['TZ']}")
end
assert_equal local_offset, DateTime.now.offset, "Failed for timezone: #{ENV['TZ']}"
end
@@ -442,7 +442,7 @@ def test_mock_time_new_same_as_now
end
def test_not_callable_send_travel
- assert_raise NoMethodError do
+ assert_raises NoMethodError do
Timecop.send_travel(:travel, Time.now - 100)
end
end
@@ -466,7 +466,7 @@ def test_datetime_to_time_for_dst_to_non_dst
def test_raises_when_safe_mode_and_no_block
with_safe_mode do
- assert_raise Timecop::SafeModeException do
+ assert_raises Timecop::SafeModeException do
Timecop.freeze
end
end
@@ -474,17 +474,13 @@ def test_raises_when_safe_mode_and_no_block
def test_no_raise_when_safe_mode_and_block_used
with_safe_mode do
- assert_nothing_raised do
- Timecop.freeze {}
- end
+ Timecop.freeze {}
end
end
def test_no_raise_when_not_safe_mode_and_no_block
with_safe_mode(false) do
- assert_nothing_raised do
- Timecop.freeze
- end
+ Timecop.freeze
end
end
diff --git a/test/timecop_without_date_but_with_time_test.rb b/test/timecop_without_date_but_with_time_test.rb
index 9531afd..5f47a31 100644
--- a/test/timecop_without_date_but_with_time_test.rb
+++ b/test/timecop_without_date_but_with_time_test.rb
@@ -1,12 +1,10 @@
-require "test/unit"
+require File.join(File.dirname(__FILE__), "test_helper")
-class TestTimecopWithoutDateButWithTime < Test::Unit::TestCase
+class TestTimecopWithoutDateButWithTime < MiniTest::Unit::TestCase
TIMECOP_LIB = File.join(File.dirname(__FILE__), '..', 'lib', 'timecop')
def test_loads_properly_when_time_is_required_instead_of_date
- assert_nothing_raised do
- require "time"
- require TIMECOP_LIB
- end
+ require "time"
+ require TIMECOP_LIB
end
end
diff --git a/test/timecop_without_date_test.rb b/test/timecop_without_date_test.rb
index 018a2ff..a6f9a0e 100644
--- a/test/timecop_without_date_test.rb
+++ b/test/timecop_without_date_test.rb
@@ -2,7 +2,7 @@
require File.join(File.dirname(__FILE__), "test_helper")
require File.join(File.dirname(__FILE__), '..', 'lib', 'timecop')
-class TestTimecopWithoutDate < Test::Unit::TestCase
+class TestTimecopWithoutDate < MiniTest::Unit::TestCase
def setup
Object.send(:remove_const, :Date) if Object.const_defined?(:Date)
@@ -19,11 +19,11 @@ def test_freeze_changes_and_resets_time
assert !Time.respond_to?(:zone) || Time.zone.nil?
t = Time.local(2008, 10, 10, 10, 10, 10)
- assert_not_equal t, Time.now
+ assert t != Time.now
Timecop.freeze(2008, 10, 10, 10, 10, 10) do
assert_equal t, Time.now
end
- assert_not_equal t, Time.now
+ assert t != Time.now
end
def test_recursive_freeze
@@ -47,7 +47,7 @@ def test_exception_thrown_in_freeze_block_properly_resets_time
raise "blah exception"
end
rescue
- assert_not_equal t, Time.now
+ assert t != Time.now
assert_nil Time.send(:mock_time)
end
end
--
1.9.3

@ -1,80 +0,0 @@
*** test/test_time_stack_item.rb 2010-10-14 13:41:21.951740293 +0200
--- test/test_time_stack_item.rb.new 2010-10-14 13:50:04.133696011 +0200
***************
*** 97,105 ****
Timecop.freeze(DateTime.parse("2009-10-1 00:38:00 -0400"))
t = DateTime.parse("2009-10-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
! assert Time.now.dst?, "precondition"
! assert tsi.time.dst?, "precondition"
! assert_equal 0, tsi.send(:dst_adjustment)
end
def test_compute_dst_adjustment_for_non_dst_to_non_dst
--- 97,105 ----
Timecop.freeze(DateTime.parse("2009-10-1 00:38:00 -0400"))
t = DateTime.parse("2009-10-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
! #assert Time.now.dst?, "precondition"
! #assert tsi.time.dst?, "precondition"
! #assert_equal 0, tsi.send(:dst_adjustment)
end
def test_compute_dst_adjustment_for_non_dst_to_non_dst
***************
*** 115,123 ****
Timecop.freeze(DateTime.parse("2009-10-1 00:38:00 -0400"))
t = DateTime.parse("2009-12-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
! assert Time.now.dst?, "precondition"
! assert !tsi.time.dst?, "precondition"
! assert_equal 60 * 60, tsi.send(:dst_adjustment)
end
def test_compute_dst_adjustment_for_non_dst_to_dst
--- 115,123 ----
Timecop.freeze(DateTime.parse("2009-10-1 00:38:00 -0400"))
t = DateTime.parse("2009-12-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
! #assert Time.now.dst?, "precondition"
! #assert !tsi.time.dst?, "precondition"
! #assert_equal 60 * 60, tsi.send(:dst_adjustment)
end
def test_compute_dst_adjustment_for_non_dst_to_dst
***************
*** 125,132 ****
t = DateTime.parse("2009-10-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
assert !Time.now.dst?, "precondition"
! assert tsi.time.dst?, "precondition"
! assert_equal -1 * 60 * 60, tsi.send(:dst_adjustment)
end
# Ensure DateTime's handle changing DST properly
--- 125,132 ----
t = DateTime.parse("2009-10-11 00:00:00 -0400")
tsi = Timecop::TimeStackItem.new(:freeze, t)
assert !Time.now.dst?, "precondition"
! #assert tsi.time.dst?, "precondition"
! #assert_equal -1 * 60 * 60, tsi.send(:dst_adjustment)
end
# Ensure DateTime's handle changing DST properly
***************
*** 136,142 ****
tsi = Timecop::TimeStackItem.new(:freeze, t)
assert_date_times_equal t, tsi.datetime
# verify Date also 'moves backward' an hour to change the day
! assert_equal Date.new(2009, 10, 10), tsi.date
end
def test_datetime_for_non_dst_to_dst
--- 136,142 ----
tsi = Timecop::TimeStackItem.new(:freeze, t)
assert_date_times_equal t, tsi.datetime
# verify Date also 'moves backward' an hour to change the day
! #assert_equal Date.new(2009, 10, 10), tsi.date
end
def test_datetime_for_non_dst_to_dst

@ -2,19 +2,20 @@
Summary: Provides a unified method to mock Time.now, Date.today in a single call
Name: rubygem-%{gem_name}
Version: 0.3.5
Release: 10%{?dist}
Version: 0.7.1
Release: 1%{?dist}
Group: Development/Languages
License: MIT
URL: http://github.com/jtrupiano/timecop
URL: https://github.com/travisjeffery/timecop
Source0: http://rubygems.org/downloads/%{gem_name}-%{version}.gem
Patch0: %{name}-failed-assert-fix.patch
Requires: ruby(release)
Requires: ruby(rubygems)
# Go with plain minitest.
# https://github.com/travisjeffery/timecop/commit/c30897f67ad90f0582c0ed0d7b78f46a7142f113
Patch0: rubygem-timecop-0.7.1-Use-minitest.patch
BuildRequires: rubygems-devel
BuildRequires: rubygem(activesupport)
BuildRequires: rubygem(minitest)
BuildRequires: rubygem(mocha)
BuildArch: noarch
Provides: rubygem(%{gem_name}) = %{version}
%description
A gem providing "time travel" and "time freezing" capabilities, making it dead
@ -27,13 +28,14 @@ Group: Documentation
Requires:%{name} = %{version}-%{release}
%description doc
Documentation for %{name}
Documentation for %{name}.
%prep
%setup -q -c -T
%gem_install -n %{SOURCE0}
pushd .%{gem_instdir}
%patch0
%patch0 -p1
popd
%build
@ -43,34 +45,34 @@ rm -rf %{buildroot}
mkdir -p %{buildroot}%{gem_dir}
cp -va ./%{gem_dir}/* %{buildroot}%{gem_dir}
# Fix permissions.
chmod a+x %{buildroot}%{gem_instdir}/test/run_tests.sh
%check
pushd %{buildroot}/%{gem_instdir}/test
mv test_time_stack_item.rb disabled_test_time_stack_item.rb
%_bindir/ruby -I../lib:. test_time*.rb
mv disabled_test_time_stack_item.rb test_time_stack_item.rb
popd
pushd .%{gem_instdir}/test
# Drop Bundler dependency.
sed -i '/bundler\/setup/ s/^/#/' test_helper.rb
%clean
rm -rf %{buildroot}
./run_tests.sh
popd
%files
%defattr(-, root, root, -)
%dir %{gem_instdir}
%{gem_libdir}
%doc %{gem_instdir}/LICENSE
%doc %{gem_instdir}/README.rdoc
%doc %{gem_instdir}/History.rdoc
%doc %{gem_instdir}/VERSION.yml
%{gem_cache}
%doc %{gem_instdir}/README.markdown
%exclude %{gem_cache}
%{gem_spec}
%files doc
%defattr(-, root, root, -)
%{gem_instdir}/test
%{gem_instdir}/Rakefile
%{gem_docdir}
%changelog
* Thu Jul 10 2014 Vít Ondruch <vondruch@redhat.com> - 0.7.1-1
- Update to Timecop 0.7.1.
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.5-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
@ -95,7 +97,7 @@ rm -rf %{buildroot}
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.3.5-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Thu Nov 09 2010 Michal Fojtik <mfojtik@redhat.com> - 0.3.5-2
* Tue Nov 09 2010 Michal Fojtik <mfojtik@redhat.com> - 0.3.5-2
- Disabled test_time_stack_item test
* Thu Oct 14 2010 Michal Fojtik <mfojtik@redhat.com> - 0.3.5-1

@ -1 +1 @@
d2043669f11eca7fabaa0b222250b942 timecop-0.3.5.gem
9974d526bd839a0331d641f3571c4293 timecop-0.7.1.gem

Loading…
Cancel
Save