I have a custom function, for kicks:
def find_newest
Card.find(:last)
end
In my unit test I want to:
assert_kind_of(Card,Card.find_newest)
But I get the “method not found” error.
What am I missing?
-Tom
I have a custom function, for kicks:
def find_newest
Card.find(:last)
end
In my unit test I want to:
assert_kind_of(Card,Card.find_newest)
But I get the “method not found” error.
What am I missing?
-Tom
Rather, it should be noted that find_newest is in my model…
I answered my own thought… in the unit test, I have an object,
created via fixtures, @c and I am able to call the proper method, and
get back the proper value, passing the assertion.
(I figured I would stuff “find newest” into the model)
And don’t write the Card constant within the method once you do this,
since self in a class method is the class.
def self.find_newest
find(:last)
end
On Jun 16, 3:23 pm, Frederick C. [email protected]
In my unit test I want to:
assert_kind_of(Card,Card.find_newest)
But I get the “method not found” error.
After you apply the ‘def self.find_newest’, look up my assert_latest, to
learn
its Card.maximum(:id) trick:
Note that the online version of assert_latest is fully productized…
On Jun 16, 8:16 pm, “sullivan.t” [email protected] wrote:
I answered my own thought… in the unit test, I have an object,
created via fixtures, @c and I am able to call the proper method, and
get back the proper value, passing the assertion.
What you shoud probably do is create find_newest as a class method, ie
def self.find_newest
…
end
rather than requiring an instance of the class for something that is
not specific to any particular instance
Fred
Interesting.
Thanks for the thoughts, guys!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs