I'm running tests on Post:
expect(subject.query).to eq [previous_post, post, future_comment]
But I get this error :
expected: [#<Post id: 3, body: "Sed quis aut harum. Asperiores ad commodi tempore ...", ...>]
got: #<ActiveRecord::Relation [#<Post id: 3, body: "Sed quis aut harum. Asperiores a.....>]>
It expected an array but get an active record object. How can I resolve that ?
This is the code i'm testing :
def query
scope = Post
.where(user_id: user.id)
.my_scope
.my_other_scope
.includes(:body)
scope = case @options[:order_by]
when "older"
order_by_older(scope)
when "most_discussed"
order_by_most_discussed(scope)
else
order_by_older(scope)
end
scope
end