[rspec-users] find_all_by returning nil

David Chelimsky dchelimsky at gmail.com
Mon Aug 11 14:51:17 EDT 2008

On Mon, Aug 11, 2008 at 1:47 PM, John Mark <lists at ruby-forum.com> wrote:
> David Chelimsky wrote:
>> On Mon, Aug 11, 2008 at 1:31 PM, Craig Demyanovich
>> <cdemyanovich at gmail.com> wrote:
>>> Looks like this line
>>> Product.stub(!find_all_by_category_id).with(anything()).and_return([product])
>>> might be the culprit. It should be stub!(find... instead of stub(!find....
>> Actually, stub!(:find....
> Sorry that was a typo
> Its actually stub! in my code

The original example doesn't seem to do anything:

it "should find products given a category" do
  product = mock_model(Product, :id => 1, :category_id => 1)

It just sets up some objects but never actually calls an action. What
is the error message you're getting?

More information about the rspec-users mailing list