views:

22

answers:

1

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: false

comment_b: id: 2 text: 'bar' visible: true

comment_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?

+1  A: 

You need made the request by your ActiveRecord Object. Comments.all(:conditions => {:visible => true})

shingara