RSpec: testing AR crawlers without getting into the database

How can I check the next crawler with RSpec?

def self.find_by_mbid(mbid) super(mbid.downcase()) end 

The only way I can see this possible is to store it in the database in advance, which I would like to avoid, since this is a unit test. I do not see how to return the mockery here, since super almost not available for RSpec.

Is there a better way to do this? Or are these levels too low for this type?

+4
source share
1 answer

You can mock it if you want to change the implementation, but I recommend spec'ing finders with a database.

+5
source

Source: https://habr.com/ru/post/1385267/


All Articles