How to write unit tests for STI associations Ruby on Rails?

There is absolutely nothing special in STI relationships that you should write test cases about. Since this is a functionality provided by framework, the frameworks comes with a bunch of testcases You only need to write testcases for the functionality you are building.

There is absolutely nothing special in STI relationships that you should write test cases about. Since this is a functionality provided by framework, the frameworks comes with a bunch of testcases. You only need to write testcases for the functionality you are building.

What if there is some code in the STI child classes i.e. Methods that is being executed after the initialization of the class. I think it would be wise to test that code.

– Rohit Sep 23 '10 at 9:17 Well yes, as I said, if you customized it, then you will need to run the built-in tests. Also, built-in STI modules will ensure the correct instance of class is loaded, depending on type, so if you are changing that, then you can write test case along those lines. My point being, there is nothing generic about STI.

Post some code if you have any and we can take it from there. – Swanand Sep 23 '10 at 9:55 one of the child classes helps in uploading files another child class is used to store multiple choice answers. And there is a column "value" in the STI parent, where the name of the uploaded file is stored and also the choices selected by the user are saved in that column with each choice having its own record.

Hope you have a better idea of the situation now. – Rohit Sep 24 '10 at 5:06.

Test all 3 classes as you would normally test any individual class: class Person Should == "George Washington" end end describe Doctor do describe "#formatted_name" do doctor = Doctor. New doctor. Formatted_name.

Should == "Dr. George Washington" end end describe Guy do describe "#formatted_name" do guy = Guy. New guy. Formatted_name.

Should == "Mr. George Washington" end end.

How to write unit tests for STI associations Ruby on Rails - Stack Overflow.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions