I have a YML file containing fixtures for a Rails model (Comment) which looks like this (pardon the formatting):
comment_a:
id: 1
text: ‘foo’
visible: falsecomment_b:
id: 2
text: ‘bar’
visible: truecomment_c:
id: 3
text: ‘baz’
visible: true
I know that I can select an individual Comment fixture like so:
comments(:comment_a)
In one of my acceptance tests, I want to find all the Comments which have visible = true. How do I select a set of Comments that meet certain criteria so I can iterate over them afterwards?
You need made the request by your ActiveRecord Object.
Comments.all(:conditions => {:visible => true})