test/progressrus_test.rb in progressrus-0.0.1 vs test/progressrus_test.rb in progressrus-0.0.2

- old
+ new

@@ -150,11 +150,12 @@ params: { job_id: 'oemg' }, started_at: nil, completed_at: nil, failed_at: nil, count: 0, - error_count: 0 + error_count: 0, + expires_at: nil } assert_equal serialization, progress.to_serializeable end @@ -371,7 +372,38 @@ def test_running_returns_true_when_job_has_ticked @progress.tick assert @progress.running? + end + + def test_expired_returns_false_when_nil + progress = Progressrus.new( + id: 'oemg', + scope: ['walruses', 'forall'] + ) + + refute progress.expired? + end + + def test_expired_returns_true_if_expires_at_in_past + time = Time.now + progress = Progressrus.new( + id: 'oemg', + scope: ['walruses', 'forall'], + expires_at: time - 3600 + ) + + assert progress.expired?(now: time) + end + + def test_expired_returns_false_if_expires_at_in_the_future + time = Time.now + progress = Progressrus.new( + id: 'oemg', + scope: ['walruses', 'forall'], + expires_at: time + 3600 + ) + + refute progress.expired?(now: time) end end