I'm a newcomer to the list. Appologies if this has been discussed before,
but all I could find with regards to specing scopes relates to those that
filter records or apply sorting. What's the best way to spec a scope that
uses the includes method? For instance:
class Location < ActiveRecord.Base
belongs_to: holiday_schedule
scope: with_holiday_schedule, includes(:holiday_schedule)
end
describe Location do
describe Location, "::with_holiday_schedule"
it "includes holiday schedule information to avoid N+1 queries" do
pending "a good way to check this..."
end
end
end
I've seen some references to hooking into ActiveSupport::Notifications for
ActiveRecord SQL and then counting the SQL statements, though the code I've
seen to do this is far from pretty. Does anyone have a better idea?
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users