Kvass
Kvass

Reputation: 8434

Stop Rails Console from loading Test::Unit

I have a model named "Test" (I commented everything out of that model so all that's left is class Test end for debugging purposes) and every time I try instantiating it in the rails console I get an error that the "new" method does not exist for Test:Module. This error does not occur when instantiating any of my other models, and I think it has to do with the fact that the rails console is loading up Test::Unit or something like that (on a hunch I ran Test.constants and the console returned [:Unit], so I am pretty sure that's the issue). At any rate, there is no question that some module named Test is being run by the rails console, and I don't want this to happen. How do I avoid this? It would be highly inconvenient for me to change me class name to a different value, so if there is any way to resolve this issue that would be great~!

Upvotes: 0

Views: 198

Answers (2)

Kvass
Kvass

Reputation: 8434

I just used a simple work-around of calling my class "Exam" instead of Test, but I would like to know how to resolve this correctly without working around the issue.

Upvotes: 1

Kyle Patterson
Kyle Patterson

Reputation: 185

You could add a module and have your test class inside of it to avoid that issue. You will then need to address your class like module::class.

Upvotes: 1

Related Questions