Retrieving specific fixtures in Rails

Posted by Bilal Aslam on Stack Overflow See other posts from Stack Overflow or by Bilal Aslam
Published on 2010-03-15T18:06:16Z Indexed on 2010/03/15 18:09 UTC
Read the original article Hit count: 429

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about fixtures