I can’t seem to figure out how to assert in my test that my method which
finds 5 records is in fact returning five records.
In my model:
app/models/widget.rb
…
def self.recent_widgets
find(:all,
:conditions => “created_at <= now()”,
:limit => 5,
:order => “created_at desc”)
end
I created a widgets.yml fixture with five records in it.
In my test_widget.rb unit test I want to assert that there are in fact
five
records being returned with the recent_widgets method
I’ve gone as far as:
tests/unit/test_widget.rb
…
fixtures :widgets
def test_find_recent_widgets
w = widget.recent_widgets
assert_not_nil w
end
Any clues. Thanks!
David Andrew T.
http://www.davidandrewthompson.com