I've just upgraded aasm gem to latest version and now I have a failing shoulda matcher (version 2.8.0) spec. The code is pretty standard, I have a Bookmark model which belongs to a user and a bookmarkable (polymorphic) item. A given user can only bookmark items once thus I have this spec:
it { should validate_uniqueness_of(:user_id).scoped_to(:bookmarkable_id, :bookmarkable_type) }
Running this spec with latest aasm code raises an error. I tracked the error to this line in aasm code. The issue is that the bookmarkable item (passed in matcher by shoulda code) does not retain its original class.
In my spec setup I create a Bookmark using a factory and matcher code uses that factory to compute values for assertion. My factory returns an instance of Place for bookmarkable while in some way the class of bookmarkable used in matcher is
class Shoulda::Matchers::ActiveRecord::Uniqueness::TestModels::Placf < ActiveRecord::Base
That name is likely generated by this code, however I don't know its purpose.
In any case I think that test models generated by your matcher should behave like original one, so they should return original class when #class is called on their instance.
I've just upgraded aasm gem to latest version and now I have a failing shoulda matcher (version 2.8.0) spec. The code is pretty standard, I have a
Bookmarkmodel which belongs to a user and a bookmarkable (polymorphic) item. A given user can only bookmark items once thus I have this spec:Running this spec with latest aasm code raises an error. I tracked the error to this line in aasm code. The issue is that the bookmarkable item (passed in matcher by shoulda code) does not retain its original class.
In my spec setup I create a Bookmark using a factory and matcher code uses that factory to compute values for assertion. My factory returns an instance of
Placefor bookmarkable while in some way the class of bookmarkable used in matcher isThat name is likely generated by this code, however I don't know its purpose.
In any case I think that test models generated by your matcher should behave like original one, so they should return original class when
#classis called on their instance.