ruby on rails - RSpec: check if any model has been saved -
in rails application i've created method creates model hierarchy basing on json data. i'd assure method not save database. know can write test like:
expect { importer.import(json) }.not_to change(model1, :count) expect { importer.import(json) }.not_to change(model2, :count) # etc.
but i'd in more generic way. there method in rspec check if model had been saved during test?
not sure if rspec help this, quick manual trip database might job?
[model1, model2].each |model| model.where('updated_at > ?', time.now - 2.seconds).count.should eq 0 end
ruby-on-rails database rspec mocking
No comments:
Post a Comment