Skip to content

Commit

Permalink
allow no opts to be passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Stephens committed Sep 12, 2014
1 parent 5d30ac8 commit ca43097
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/with_timed_cache.rb
Expand Up @@ -2,7 +2,7 @@
require "with_timed_cache/caches"

module WithTimedCache
def with_timed_cache(key, opts)
def with_timed_cache(key, opts = {})
cache = Caches.find_or_create(key, opts)

if cache.exists? && !cache.stale?
Expand Down
7 changes: 7 additions & 0 deletions spec/with_timed_cache_spec.rb
Expand Up @@ -13,6 +13,13 @@
clean_cache_directory
end

it "does not require opts to be passed" do
val = "NO OPTS"
FileUtils.mkdir_p("tmp")
data = with_timed_cache(:no_opts) { val }
expect(data).to eql(val)
end

it "caches data for a defined max_age" do
original_val = "original value"
updated_val = "updated value"
Expand Down

0 comments on commit ca43097

Please sign in to comment.