Skip to content

Commit

Permalink
fix rspec test to work with AR 7.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
6 committed Apr 10, 2024
1 parent 57d2055 commit 26a4337
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spec/activerecord-explain-analyze_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
context "without any args" do
it "returns normal explain output" do
output = Car.where(model: "bmw").explain
expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
# AR 7.1+ has slightly different output:
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
expect(output).to start_with(%{EXPLAIN SELECT "cars"})
else
expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
end
expect(output).not_to include("actual time")
end
end
Expand Down

0 comments on commit 26a4337

Please sign in to comment.