puts Book.find_by_contents("rrrrr").inspect
will tell you what the method returned. Or if you want to go fancy,
use Rails.logger.debug instead of plain puts and the output will go to
your test.log.
//jarkko
>
>
> Thanks,
>
> Akkdio
> >
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
>
> Thanks,
>
> This is the return:
>
> ..#<ActsAsFerret::SearchResults:0x25a36f4 @total_pages=0, @results=[],
> @per_page=0, @current_page=nil, @total_hits=0>
>
> I guess the reason the test does not fail is because we are asserting
> ferret worked but do not require it to return the book. It does its
> job by not finding the book because the book does not exists. Why is
> this test, assert Book.find_by_contents("Pride and Prejudice"), used.
> Is it just to see if it works - doesn't the test: assert_equal 1,
> Book.find_by_contents("Open Source").size, play this role too?
I think the behaviour of acts_as_ferret has changed since the writing
of the book. It used to just return nil when there were no hits.
Checking the size is definitely the way to go now.
//jarkko
>
>
>
> On Oct 2, 1:41 am, Jarkko Laine <jar...@jlaine.net> wrote:
>> On 2.10.2008, at 5.10, akkdio wrote:
>>
>>
>>
>>> I am getting a false positive on the book test for test_ferret.
>>> When
>>> I change the books assert method:
>>
>>> assert Book.find_by_contents("Pride and Prejudice") to
>>> assert Book.find_by_contents("rrrrr")
>>
>>> it still passes. Any hints to why this is.
>>
>>> everything works fine for ferret but I like to break things to
>>> understand how they are working and this did not break.
>>
>> puts Book.find_by_contents("rrrrr").inspect
>>
>> will tell you what the method returned. Or if you want to go fancy,
>> use Rails.logger.debug instead of plain puts and the output will go
>> to
>> your test.log.
>>
>> //jarkko
>>
>>
>>
>>> Thanks,
>>
>>> Akkdio
>>
>> --
>> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce.comhttp
>> ://odesign.fi
> >
--