diff --git a/spec/components/distributed_cache_spec.rb b/spec/components/distributed_cache_spec.rb index f41e2221c..ccd75d5e9 100644 --- a/spec/components/distributed_cache_spec.rb +++ b/spec/components/distributed_cache_spec.rb @@ -3,18 +3,6 @@ require 'distributed_cache' describe DistributedCache do - def wait_for(&blk) - i = 0 - result = false - while !result && i < 300 - result = blk.call - i += 1 - sleep 0.001 - end - - result.should == true - end - let! :cache1 do DistributedCache.new("test") end diff --git a/spec/models/site_text_spec.rb b/spec/models/site_text_spec.rb index 3823e9847..f775b1a2e 100644 --- a/spec/models/site_text_spec.rb +++ b/spec/models/site_text_spec.rb @@ -22,12 +22,17 @@ describe SiteText do SiteText.text_for("got.sso").frozen? == true SiteSetting.enable_sso = true - SiteText.text_for("got.sso").should == "got sso: true" + wait_for do + SiteText.text_for("got.sso") == "got sso: true" + end text.value = "I gots sso: %{enable_sso}" text.save! - SiteText.text_for("got.sso").should == "I gots sso: true" + wait_for do + SiteText.text_for("got.sso") == "I gots sso: true" + end + SiteText.text_for("got.sso", enable_sso: "frog").should == "I gots sso: frog" end diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 1ae65ea4b..3a2df52cd 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -51,4 +51,17 @@ module Helpers yield(guardian) if block_given? Guardian.stubs(new: guardian).with(user) end + + def wait_for(&blk) + i = 0 + result = false + while !result && i < 300 + result = blk.call + i += 1 + sleep 0.001 + end + + result.should == true + end + end