jeudi 27 avril 2017

Testing if Undefined method error occures

In my Rails project I'm testing one of my model's :currency attribute presence validation.

I'm also using Money gem and in case of creating a model without a :currency attribute it gives me following error:

"NoMethodError Exception: undefined method `subunit_to_unit' for nil:NilClass"

Because of this my assert(account).invalid? test does not fail, but gives error.

How should I rewrite my test now so that it checks for error occurence instead of model validation?

Or should I do something else in the model instead?

Aucun commentaire:

Enregistrer un commentaire