Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/configatron/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def fetch(key, default_value = nil, &block)
else
if block
val = block.call
elsif default_value
else
val = default_value
end
store(key, val)
Expand Down
5 changes: 5 additions & 0 deletions test/unit/configatron/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class Critic::Unit::StoreTest < Critic::Unit::Test
assert_equal("bar!!", @store.bar)
end

it "sets and returns default_value if default is falsey" do
assert_equal(false, @store.fetch(:bar, false))
assert_equal(false, @store.bar)
end

it "sets and returns the value of the block if no value is found" do
@store.fetch(:bar) do
"bar!"
Expand Down