Empty string and nil values help needed

I have done many variations of this code. Essentially I want this
to be
true.

assert_equal '', Org.field_for(nil).display

You've overridden it so I doubt this is the problem, but display is a
built-in method at a very basic level (somewhere near inspect) so
maybe that's messing you up in case you aren't overriding it correctly.

This is a polymorphic relationship.

fieldable.rb

def field_for(purpose)
self.fields.find(
  :first,
  :conditions => ["purpose LIKE ?", "#{purpose}"],

Are you sure you didn't mean ["purpose LIKE ?", purpose] There's no
reason to quote the second argument. Although I don't know what Rails
does when you pass in nil to conditions like that. Maybe it doesn't
like that.

  :order => 'position asc')
end # def

field.rb

def display
str = ""
field.to_s unless search.blank?
str
end

Can someone help tell me what I'm doing wrong and why I can't
produce an
empty string? I had thought that nil.to_s created an empty string,
but
just writing the following didn't work either.

It does.

>> nil.to_s
=> ""

So, something else is wrong somewhere...

What does the application stack trace say?

James Byrne wrote:

What does the application stack trace say?

Is there an easy way to generate this from a test?

Marnen Laibow-Koser wrote:

The trace should be in test.log.

This code is in a plugin. To run tests, I'm running them directly out
of the vendor/plugins directory. Any ideas how to write a test.log
there?