Skip to content
Merged
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
32 changes: 32 additions & 0 deletions spec/lucky/cookies/flash_store_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,38 @@ describe Lucky::FlashStore do
end
end

describe "#any?" do
it "returns true if there are key/value pairs" do
flash_store = build_flash_store(next: {
"some_key" => "some_value",
})

flash_store.any?.should be_true
end

it "returns false if there are no key/value pairs" do
flash_store = build_flash_store

flash_store.any?.should be_false
end
end

describe "#empty?" do
it "returns false if there are key/value pairs" do
flash_store = build_flash_store(next: {
"some_key" => "some_value",
})

flash_store.empty?.should be_false
end

it "returns true if there are no key/value pairs" do
flash_store = build_flash_store

flash_store.empty?.should be_true
end
end

describe "#all" do
it "prefers values from @next over @now" do
next_hash = {"name" => "Paul"}
Expand Down
2 changes: 1 addition & 1 deletion src/lucky/cookies/flash_store.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Lucky::FlashStore
SESSION_KEY = "_flash"
alias Key = String | Symbol

delegate each, to: all
delegate any?, each, empty?, to: all

@now = {} of String => String
@next = {} of String => String
Expand Down