[rspec-users] find_all_by returning nil

2008-08-11 Thread John Mark
The statement products = find_all_by_category_id(category_id) in the Product model is returning nil with rspec. I am expecting it to to return value for the stub that I provided it with. It does not also work with fixtures. Product model def self.find_all_meeting_some_criteria_for_category(cate

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread John Mark
David Chelimsky wrote: > On Mon, Aug 11, 2008 at 1:31 PM, Craig Demyanovich > <[EMAIL PROTECTED]> 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 > >

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread John Mark
David Chelimsky wrote: > On Mon, Aug 11, 2008 at 1:47 PM, John Mark <[EMAIL PROTECTED]> wrote: >> >> Sorry that was a typo >> >> Its actually stub! in my code > > The original example doesn't seem to do anything: > > it "should find product

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread John Mark
David Chelimsky wrote: > On Mon, Aug 11, 2008 at 2:49 PM, John Mark <[EMAIL PROTECTED]> wrote: >>> product = mock_model(Product, :id => 1, :category_id => 1) >>> >>> Product.stub(!find_all_by_category_id).with(anything()).and_return([p

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread John Mark
> It just looks as if (based on logs) that no database call is made in the > real application when I make this call with rspec (although it works ok > without rspec) > products = find_all_by_category_id(category_id) > The error is generated in the statement following the above statement > product