File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2711,3 +2711,26 @@ def test_relation_explain_with_last_coerced
2711
2711
assert_match ( expected_query , message )
2712
2712
end
2713
2713
end
2714
+
2715
+ module ActiveRecord
2716
+ module Assertions
2717
+ class QueryAssertionsTest < ActiveSupport ::TestCase
2718
+ # Query slightly different in original test.
2719
+ coerce_tests! :test_assert_queries_match
2720
+ def test_assert_queries_match_coerced
2721
+ assert_queries_match ( /ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY/i , count : 1 ) { Post . first }
2722
+ assert_queries_match ( /ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY/i ) { Post . first }
2723
+
2724
+ error = assert_raises ( Minitest ::Assertion ) {
2725
+ assert_queries_match ( /ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY/i , count : 2 ) { Post . first }
2726
+ }
2727
+ assert_match ( /1 instead of 2 queries/ , error . message )
2728
+
2729
+ error = assert_raises ( Minitest ::Assertion ) {
2730
+ assert_queries_match ( /ASC OFFSET 0 ROWS FETCH NEXT @0 ROWS ONLY/i , count : 0 ) { Post . first }
2731
+ }
2732
+ assert_match ( /1 instead of 0 queries/ , error . message )
2733
+ end
2734
+ end
2735
+ end
2736
+ end
You can’t perform that action at this time.
0 commit comments