Business intelligence made simple
DRY test code [skip ci]
Andrew Kane19c77c016442
diff --git a/test/cache_test.rb b/test/cache_test.rbindex 325ecd11..8b91f538 100644--- a/test/cache_test.rb+++ b/test/cache_test.rb@@ -6,7 +6,7 @@ class CacheTest < ActionDispatch::IntegrationTestenddef test_all- Blazer.data_sources["main"].stub(:cache, {"mode" => "all"}) do+ with_caching({"mode" => "all"}) dorun_query "SELECT 1"refute_match "Cached", response.bodyrun_query "SELECT 1"@@ -15,7 +15,7 @@ class CacheTest < ActionDispatch::IntegrationTestenddef test_slow_under_threshold- Blazer.data_sources["main"].stub(:cache, {"mode" => "slow"}) do+ with_caching({"mode" => "slow"}) dorun_query "SELECT 1"refute_match "Cached", response.bodyrun_query "SELECT 1"@@ -24,7 +24,7 @@ class CacheTest < ActionDispatch::IntegrationTestenddef test_slow_over_threshold- Blazer.data_sources["main"].stub(:cache, {"mode" => "slow", "slow_threshold" => 0.01}) do+ with_caching({"mode" => "slow", "slow_threshold" => 0.01}) dorun_query "SELECT pg_sleep(0.01)::text"refute_match "Cached", response.bodyrun_query "SELECT pg_sleep(0.01)::text"@@ -33,8 +33,16 @@ class CacheTest < ActionDispatch::IntegrationTestenddef test_variables- Blazer.data_sources["main"].stub(:cache, {"mode" => "all"}) do+ with_caching({"mode" => "all"}) dorun_query "SELECT {str_var}, {int_var}", str_var: "hello", int_var: 1endend++ private++ def with_caching(value)+ Blazer.data_sources["main"].stub(:cache, value) do+ yield+ end+ endend