In my app, I want to define a class that my models, views, and controllers will use. My thought was to create a new directory, app/lib
, where I created:
# /app/lib/donut.rb
class Donut
def initialize(sprinkle_color)
@sprinkle_color = sprinkle_color
end
def sprinkle_color
@sprinkle_color
end
end
Now this works fine, but when I added test/lib
, those tests are not run when I run rake test
. I can run rake test:all
which works, but feels wrong.
Is this the right place to put classes, and if so, how do I get them into the tests?
P.S. Why do I need a class like this? Of course, I'm not actually creating a donut. It's a class that takes a set of arguments, and there are many models that have these objects. In addition, there are views that take these objects, or arrays of these objects. Finally, there is code that operates on lists of these objects, and I've put that code as static methods into this class.