mirror of
https://github.com/discourse/discourse.git
synced 2024-12-18 18:45:59 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
30 lines
749 B
Ruby
30 lines
749 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "DistributedCache extensions" do
|
|
let(:cache) { DistributedCache.new('mytest') }
|
|
|
|
it "can defer_get_set" do
|
|
messages = MessageBus.track_publish("/distributed_hash") do
|
|
cache.defer_get_set("key") { "value" }
|
|
end
|
|
expect(messages.size).to eq(1)
|
|
expect(cache["key"]).to eq("value")
|
|
end
|
|
|
|
it "works correctly for nil values" do
|
|
block_called_counter = 0
|
|
messages = MessageBus.track_publish("/distributed_hash") do
|
|
2.times do
|
|
cache.defer_get_set("key") do
|
|
block_called_counter += 1
|
|
nil
|
|
end
|
|
end
|
|
end
|
|
|
|
expect(block_called_counter).to eq(1)
|
|
expect(messages.size).to eq(1)
|
|
expect(cache["key"]).to eq(nil)
|
|
end
|
|
end
|