From 5968d7a65886d3450698889f685eccaf54749f43 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 7 Mar 2011 09:36:07 -0800 Subject: do not test explicit equality of predicate methods, they should be allowed to return truthy or falsey objects --- activesupport/lib/active_support/cache.rb | 6 +----- activesupport/test/caching_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index e2b7b0707b..10c457bb1d 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -590,11 +590,7 @@ module ActiveSupport # Check if the entry is expired. The +expires_in+ parameter can override the # value set when the entry was created. def expired? - if @expires_in && @created_at + @expires_in <= Time.now.to_f - true - else - false - end + @expires_in && @created_at + @expires_in <= Time.now.to_f end # Set a new time when the entry will expire. diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 579d5dad24..e5668e29d7 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -679,12 +679,12 @@ class CacheEntryTest < ActiveSupport::TestCase def test_expired entry = ActiveSupport::Cache::Entry.new("value") - assert_equal false, entry.expired? + assert !entry.expired?, 'entry not expired' entry = ActiveSupport::Cache::Entry.new("value", :expires_in => 60) - assert_equal false, entry.expired? + assert !entry.expired?, 'entry not expired' time = Time.now + 61 Time.stubs(:now).returns(time) - assert_equal true, entry.expired? + assert entry.expired?, 'entry is expired' end def test_compress_values -- cgit v1.2.3