Skip to content

Commit 5370814

Browse files
committed
Fix explain test comparisons
Explain now returns an object. We need to coerce it into a string for rspec comparisons. https://blog.saeloun.com/2024/11/21/rails-7-2-adds-support-for-explain-method-to-activerecord-relation/ rails/rails@c1ea574
1 parent d673594 commit 5370814

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ class ::TestPost < ActiveRecord::Base
354354

355355
it "should explain query" do
356356
explain = TestPost.where(id: 1).explain
357-
expect(explain).to include("Cost")
358-
expect(explain).to include("INDEX UNIQUE SCAN")
357+
expect(explain.inspect).to include("Cost")
358+
expect(explain.inspect).to include("INDEX UNIQUE SCAN")
359359
end
360360

361361
it "should explain query with binds" do
362362
binds = [ActiveRecord::Relation::QueryAttribute.new("id", 1, ActiveRecord::Type::OracleEnhanced::Integer.new)]
363363
explain = TestPost.where(id: binds).explain
364-
expect(explain).to include("Cost")
365-
expect(explain).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL")
364+
expect(explain.inspect).to include("Cost")
365+
expect(explain.inspect).to include("INDEX UNIQUE SCAN").or include("TABLE ACCESS FULL")
366366
end
367367
end
368368

@@ -768,13 +768,13 @@ class ::TestPost < ActiveRecord::Base
768768
it "should explain considers hints" do
769769
post = TestPost.optimizer_hints("FULL (\"TEST_POSTS\")")
770770
post = post.where(id: 1)
771-
expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |")
771+
expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |")
772772
end
773773

774774
it "should explain considers hints with /*+ */" do
775775
post = TestPost.optimizer_hints("/*+ FULL (\"TEST_POSTS\") */")
776776
post = post.where(id: 1)
777-
expect(post.explain).to include("| TABLE ACCESS FULL| TEST_POSTS |")
777+
expect(post.explain.inspect).to include("| TABLE ACCESS FULL| TEST_POSTS |")
778778
end
779779
end
780780

0 commit comments

Comments
 (0)