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

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread Pat Maddox
> Sorry again I forgot to add the last statement Could you just copy and paste your code? That would be infinitely more helpful. Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

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([product]) >>> >>> Product.should_receive(:find_all_meetin

Re: [rspec-users] find_all_by returning nil

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

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 products given a category" do > product = mock_model(Product,

Re: [rspec-users] Someone please name this matcher for me

2008-08-11 Thread Joseph Wilk
On 07/08/2008, at 05:04 , Jonathan Linowes wrote: > .should be_bag_of( [1, 3, 1, 4, 2] ) +1 -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] find_all_by returning nil

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

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 David Chelimsky
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 Actually, stub!(:find > > Regar

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread MaurĂ­cio Linhares
And i think that stubbed classes or objects can not access the database. On Mon, Aug 11, 2008 at 3: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 stu

Re: [rspec-users] find_all_by returning nil

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

Re: [rspec-users] find_all_by returning nil

2008-08-11 Thread Craig Demyanovich
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 Regards, Craig ___ rspec-users mailing list rspec-users@rubyforge.org http://r

[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] Someone please name this matcher for me

2008-08-11 Thread Matt Wynne
Would such a matcher also work in this instance: Car.should_receive(:find).with([EMAIL PROTECTED], @fiat.id]) Such that if I don't know (or care) what order the IDs will be passed to the find method, this will pass? Or is there already some other way to achieve that? -- Posted via http://www.r

Re: [rspec-users] calls with block in views

2008-08-11 Thread David Chelimsky
On Mon, Aug 11, 2008 at 2:05 AM, Yury Kotlyarov <[EMAIL PROTECTED]> wrote: > Hi! > > I have a view: > > <% restrict_to 'admin' do %> > > <%= render :partial => 'detail' %> > > <% end %> > > What's the best way to spec view in this case - I just want to yield block > in restrict_to call. Here

[rspec-users] calls with block in views

2008-08-11 Thread Yury Kotlyarov
Hi! I have a view: <% restrict_to 'admin' do %> <%= render :partial => 'detail' %> <% end %> What's the best way to spec view in this case - I just want to yield block in restrict_to call. Thanks in advance, Yury ___ rspec-users mailing list