Skip to content

Business intelligence made simple

Removed stub calls for minitest 6 [skip ci]

Andrew Kanecda46c59d283
diff --git a/test/anomaly_checks_test.rb b/test/anomaly_checks_test.rb
index 2066aee1..72ce98ad 100644
--- a/test/anomaly_checks_test.rb
+++ b/test/anomaly_checks_test.rb
@@ -25,7 +25,7 @@ class AnomalyChecksTest < ActionDispatch::IntegrationTest
def assert_anomaly(anomaly_checks)
skip if !postgresql? || RUBY_ENGINE == "truffleruby"
- Blazer.stub(:anomaly_checks, anomaly_checks) do
+ with_option(:anomaly_checks, anomaly_checks) do
query = create_query(statement: "SELECT current_date + n AS day, 0.1 FROM generate_series(1, 30) n")
check = create_check(query: query, check_type: "anomaly")
diff --git a/test/cache_test.rb b/test/cache_test.rb
index 3428ac09..14e40446 100644
--- a/test/cache_test.rb
+++ b/test/cache_test.rb
@@ -44,8 +44,12 @@ class CacheTest < ActionDispatch::IntegrationTest
private
def with_caching(value)
- Blazer.data_sources["main"].stub(:cache, value) do
+ data_source = Blazer.data_sources["main"]
+ begin
+ data_source.instance_variable_set(:@cache, value)
yield
+ ensure
+ data_source.remove_instance_variable(:@cache)
end
end
end
diff --git a/test/forecasting_test.rb b/test/forecasting_test.rb
index 433ae13d..a9883097 100644
--- a/test/forecasting_test.rb
+++ b/test/forecasting_test.rb
@@ -20,7 +20,7 @@ class ForecastingTest < ActionDispatch::IntegrationTest
def assert_forecast(forecasting)
skip unless postgresql?
- Blazer.stub(:forecasting, forecasting) do
+ with_option(:forecasting, forecasting) do
query = create_query(statement: "SELECT current_date + n AS day, n FROM generate_series(1, 30) n")
run_query query.statement, query_id: query.id, forecast: "t"
assert_match %{"name":"forecast"}, response.body
diff --git a/test/queries_test.rb b/test/queries_test.rb
index 6b491ca1..1a5a31b9 100644
--- a/test/queries_test.rb
+++ b/test/queries_test.rb
@@ -164,14 +164,14 @@ class QueriesTest < ActionDispatch::IntegrationTest
end
def test_images
- Blazer.stub(:images, true) do
+ with_option(:images, true) do
run_query("SELECT 'http://localhost:3000/image.png'")
assert_match %{<img referrerpolicy="no-referrer" src="http://localhost:3000/image.png" }, response.body
end
end
def test_async
- Blazer.stub(:async, true) do
+ with_option(:async, true) do
perform_enqueued_jobs do
run_query "SELECT 123"
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index f13ced2a..f7e9cbcc 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -37,6 +37,16 @@ class ActionDispatch::IntegrationTest
def postgresql?
ENV["ADAPTER"].nil?
end
+
+ def with_option(name, value)
+ previous_value = Blazer.send(name)
+ begin
+ Blazer.send("#{name}=", value)
+ yield
+ ensure
+ Blazer.send("#{name}=", previous_value)
+ end
+ end
end
require_relative "support/adapter_test"