jwood / tenacity

A database client independent way of managing relationships between models backed by different databases.
MIT License
118 stars 17 forks source link

Tenacity::ObjectDoesNotExistError thrown for mocks/stubs #44

Open w1150n opened 11 years ago

w1150n commented 11 years ago

In my rspec tests I use stubbed foreign id's which causes Tenacity::ObjectDoesNotExistError errors to be thrown from t_belongs_to associations. Is there a way to make existence validation optional?

jwood commented 11 years ago

There is currently no way to disable this check. The code that raises this exception is here:

https://github.com/jwood/tenacity/blob/master/lib/tenacity/instance_methods.rb#L24

The _t_verify_associates_exist method is invoked as a before_save callback on the model.

I'm not actively working on Tenacity at the moment, but I will accept pull requests if you feel like taking a crack at this.