ruby - Simulate read-only database with Rspec / Rails -
I am currently running a unit test of my RAR application. One of my controllers should return an HTTP status 500 when it can not write a new entity to the database. I want to test this behavior and just read it to read my database temporarily.
Does anybody know that it is possible to do this?
I tried the technique outlined in "", but this approach does not work for me (because the administrator reads before writing the database).
I think you are checking the controller, if you can only duplicate the model requests Are there. So, what should be the exception Model.create throw? Try doing something like this:
Model.stub (: create) .and_raise (ActiveRecord :: ReadOnlyRecord)
Comments
Post a Comment