From a37c363ecf7597861d8fc670d65175b3a344bee8 Mon Sep 17 00:00:00 2001 From: AndyObtiva Date: Tue, 24 Mar 2015 02:02:46 -0400 Subject: [PATCH] Updated spec to avoid reliance on actual time by using mocks --- spec/lib/super_module_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/lib/super_module_spec.rb b/spec/lib/super_module_spec.rb index 3dfca4a..ab281aa 100644 --- a/spec/lib/super_module_spec.rb +++ b/spec/lib/super_module_spec.rb @@ -161,6 +161,8 @@ class BazActiveRecord < FakeActiveRecord subject { BazActiveRecord } + after { allow(Time).to receive(:now).and_call_original } + it 'allows invoking class methods' do expect(subject.validations).to include(['foo', {:presence => true}]) expect(subject.validations).to include(['bar', {:presence => true}]) @@ -182,7 +184,10 @@ class BazActiveRecord < FakeActiveRecord end it 'can include a basic module (Comprable)' do + now = Time.now + allow(Time).to receive(:now).and_return(now) instance = subject.new + allow(Time).to receive(:now).and_return(now + 100) instance2 = subject.new expect(instance < instance2).to eq(true)