You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2012/08/24 20:03:58 UTC

git commit: Gogrid tests: restore Time.be for now

Updated Branches:
  refs/heads/master e3a59a235 -> b6193c55f


Gogrid tests: restore Time.be for now

Removing it led to test failures; restore it until we've found a way to
make do without it.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/b6193c55
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/b6193c55
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/b6193c55

Branch: refs/heads/master
Commit: b6193c55f4795e6ad8b39fafb696a3e7e0b76637
Parents: e3a59a2
Author: David Lutterkort <lu...@redhat.com>
Authored: Fri Aug 24 11:03:15 2012 -0700
Committer: David Lutterkort <lu...@redhat.com>
Committed: Fri Aug 24 11:03:15 2012 -0700

----------------------------------------------------------------------
 server/tests/drivers/gogrid/common.rb |   34 ++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/b6193c55/server/tests/drivers/gogrid/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/drivers/gogrid/common.rb b/server/tests/drivers/gogrid/common.rb
index 411d9ad..c7b38ca 100644
--- a/server/tests/drivers/gogrid/common.rb
+++ b/server/tests/drivers/gogrid/common.rb
@@ -1,5 +1,7 @@
 require 'vcr'
 
+require_relative '../../test_helper.rb'
+
 def credentials
   {
     :user => '9bbf139b8b57d967',
@@ -8,7 +10,36 @@ def credentials
 end
 
 unless Time.respond_to? :be
-  require_relative '../../test_helper.rb'
+  require 'time'
+
+  # This code was originally copied from:
+  # https://github.com/jtrupiano/timecop/issues/8#issuecomment-1396047
+  #
+  # Since 'timecop' gem has broken 'timezone' support, this small monkey-patching
+  # on Time object seems to fix this issue.
+
+  unless Time.respond_to? :be
+    class Time
+      module TimeMock
+        attr_accessor :mock_time
+
+        def mock_now
+          @mock_time || Time.original_now
+        end
+
+        def be(a_time)
+          @mock_time = Time.parse(a_time)
+        end
+
+      end
+
+      class << self
+        include TimeMock
+        alias_method :original_now, :now
+        alias_method :now, :mock_now
+      end
+    end
+  end
 end
 
 VCR.configure do |c|
@@ -18,4 +49,3 @@ VCR.configure do |c|
   # Set this to :new_episodes when you want to 're-record'
   c.default_cassette_options = { :record => :new_episodes }
 end
-