Skip to content

Commit

Permalink
Updated spec to avoid reliance on actual time by using mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Mar 24, 2015
1 parent b8e59f9 commit a37c363
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/lib/super_module_spec.rb
Expand Up @@ -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}])
Expand All @@ -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)
Expand Down

0 comments on commit a37c363

Please sign in to comment.