Rails, Is there a way to generate Unit Tests from Existing Controllers and methods defined in them? -


i wondering if there script can take existing codebase , generate unit tests each method in controllers. default passing since empty , can remove tests methods dont feel important.

this save huge time , increase testing. since i'd have define each method should output , not boilerplate needs written.

you shouldn't doing this. creating pointless tests technical debt don't want. take time, go through each controller , write test (or preferably few) each method. you'll thank in long run.

you can use test coverage tools see bits still need testing.

you can use shared tests avoid repetition. example rspec, add following spec_helper/rails_helper

def should_be_ok(action)   "should respond ok"     action.to_sym     expect(response).to be_success   end end 

then in controller_spec

describe usercontroller   should_be_ok(:index)   should_be_ok(:new) end 

Comments