ruby on rails 3 - Expect Rspec to raise exceptions in controller -
i trying test on controller if raises errors when mass-assignment protected attributes updated.
expect post :create, account: {protected_attr: "blahblah"} end.to raise_error
however rspec says: expected exception nothing raised
while if in spec file, remove expect block, like
post :create, account: {protected_attr: "blahblah"}
there exception when running spec:
activemodel::massassignmentsecurity::error: can't mass-assign protected attributes: protected_attr
how come rspec's raise_error not capture exception?
this not answer question might solve problem. don't have test in controller tests. test in in model specs. concern of models in rails 3.x. in rails 4 used different approach.
Comments
Post a Comment