Pokazywanie postów oznaczonych etykietą rails. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą rails. Pokaż wszystkie posty

środa, 24 sierpnia 2011

unit testing and inheritance

In my project I have Single Table Inheritance (STI). Example of STI. type:string is very important!!!

I came across an error while I tried the unit testing:

Problem:
test_the_truth(AdminTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: clients: DELETE FROM "clients" WHERE 1=1

Solution1:
delete the fixtures of chlid models, in this case table 'clients'


Solution2:
add name of the fixtures one want to add in each test:
fixtures :clients
and delete line
fixtures :all
from the test_helper.rb

binding.pry

Best screencasts about rails: http://railscasts.com
The last episode was about pry. Nice alternative to irb.
http://pry.github.com/

How to change your editor in pry? Let's do this in Ubuntu and switch from nano to vim
Just make/add to a file named '.pryrc' in your home folder

pry -r config/environment