base_factory_examples.rb 955 B

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'lib/import/import_factory_examples'
  3. RSpec.shared_examples 'Import::BaseFactory' do
  4. it_behaves_like 'Import factory'
  5. it 'responds to pre_import_hook' do
  6. expect(described_class).to respond_to('pre_import_hook')
  7. end
  8. it 'responds to post_import_hook' do
  9. expect(described_class).to respond_to('post_import_hook')
  10. end
  11. it 'responds to backend_class' do
  12. expect(described_class).to respond_to('backend_class')
  13. end
  14. it 'responds to skip?' do
  15. expect(described_class).to respond_to('skip?')
  16. end
  17. end
  18. RSpec.shared_examples 'Import::BaseFactory extender' do
  19. it 'calls new on determined backend object' do
  20. record = double
  21. allow(described_class).to receive(:backend_class).and_return(Class)
  22. allow(Class).to receive(:new)
  23. described_class.import([record])
  24. expect(Class).to have_received(:new).with(record, any_args)
  25. end
  26. end