ruby on rails - How to create fake Virtus model returned objects? -


i'm using virtus gem , have doubt:

i have method returns virtus object. want unit test calling class.

in order this, want fake return.

usually use factory girl create fake objects, din't work virtus.

how recommend that?

thanks

i suggest switch fabrication implements factory pattern absolutely can initiated ;))

if it's not option, can define test/spec helper create object you. in case use faker:

def create_my_model(opts = {})   mymodel.new({     :foo => opts.fetch(:foo) { "dynamic default foo #{rand}" },     :bar => opts.fetch(:bar, "static default baz")   }) end 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -