Unit Testing SQL

Hi

What is the best way to unit test hard coded sql in a rails application.

Gurdipe

On 22 June 2012 15:07, Gurdipe D. [email protected] wrote:

What is the best way to unit test hard coded sql in a rails application.

You don’t test SQL, you test methods. Whether the method gets it’s
results through ActiveRecord, raw SQL, or fairies rummaging around the
hard drive, it’s irrelevant to the tests. They should just be testing
that the expected values are returned by the method.

So the answer to your question may be “move the SQL to be wrapped by
methods, and test those”, but without seeing some source code it would
be hard to say.