Permalink
Browse files

Update failing test to use timecop instead of custom time stubbing

  • Loading branch information...
1 parent 891029c commit 228dab4a65d5751b06ea1486fd4fb8814143c01f @benkirzhner benkirzhner committed Oct 31, 2014
Showing with 22 additions and 17 deletions.
  1. +22 −17 spec/integration/qless_spec.rb
@@ -6,6 +6,8 @@
# Spec stuff
require 'spec_helper'
+require 'timecop'
+
module Qless
describe Client, :integration do
let(:queue) { client.queues['foo'] }
@@ -57,28 +59,31 @@ module Qless
end
it 'pops a high pri job before a low pri job when they recur at the same moment' do
- Time.freeze
-
- interval = 10
+ # some arbitrary time
+ time = Time.iso8601('2014-08-01T00:00:00Z')
- enqueue_with_priority = lambda do |priority, jid|
- q.recur(Qless::Job, {}, interval,
- :jid => jid, :offset => (interval / 2),
- :priority => priority)
- end
+ Timecop.freeze(time) do
+ interval = 10
- enqueue_with_priority[10, "low_pri"]
- enqueue_with_priority[1000, "high_pri"]
- enqueue_with_priority[100, "med_pri"]
+ enqueue_with_priority = lambda do |priority, jid|
+ queue.recur(Qless::Job, {}, interval,
+ :jid => jid, :offset => (interval / 2),
+ :priority => priority)
+ end
- Time.advance(10)
+ enqueue_with_priority[10, "low_pri"]
+ enqueue_with_priority[1000, "high_pri"]
+ enqueue_with_priority[100, "med_pri"]
+ end
- # Note: you can make this spec pass by uncommenting this line
- # q.peek(3)
+ Timecop.freeze(time + 10) do
+ # Note: you can make this spec pass by uncommenting this line
+ # q.peek(3)
- q.pop.jid.should include('high_pri')
- q.pop.jid.should include('med_pri')
- q.pop.jid.should include('low_pri')
+ queue.pop.jid.should include('high_pri')
+ queue.pop.jid.should include('med_pri')
+ queue.pop.jid.should include('low_pri')
+ end
end
end

0 comments on commit 228dab4

Please sign in to comment.