jdliss / shoulda-callback-matchers

Test existence of your Rails callbacks without having to call them
MIT License
134 stars 18 forks source link

after(:commit).on not supported #7

Closed aaronchi closed 10 years ago

aaronchi commented 10 years ago

I can't test after_commit callbacks with the on option

this is valid: after_commit :update_average_password_scores, :on => :destroy, :if => :active?

so tried to test with: it { should callback(:update_average_password_scores).after(:commit).on(:destroy).if(:active?) }

but it fails with this error:

Failure/Error: it { should callback(:update_average_password_scores).after(:commit).on(:destroy).if(:active?) }
     Shoulda::Callback::Matchers::ActiveModel::UsageError:
       The .on option is only valid for the validation lifecycle and cannot be used with commit, use with .before(:validation) or .after(:validation)
beatrichartz commented 10 years ago

It is a valid rails callback but it's not yet supported by the callback matchers. Implementation will be a bit of work though. I'll start on it in the next days.

beatrichartz commented 10 years ago

It is now supported. Released in 1.1.0