attribute_mapper_spec.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Sequencer::Unit::Common::AttributeMapper, sequencer: :unit do
  4. let(:map) do
  5. {
  6. old_key: :new_key,
  7. second: :new_second,
  8. }
  9. end
  10. it 'expects an implementation of the .map method' do
  11. expect do
  12. described_class.map
  13. end.to raise_error(RuntimeError)
  14. end
  15. it 'declares uses from map keys' do
  16. allow(described_class).to receive(:map).and_return(map)
  17. expect(described_class.uses).to eq(map.keys)
  18. end
  19. it 'declares provides from map values' do
  20. allow(described_class).to receive(:map).and_return(map)
  21. expect(described_class.provides).to eq(map.values)
  22. end
  23. it 'maps as configured' do
  24. old = {
  25. old_key: :value,
  26. second: :second_value,
  27. }
  28. allow(described_class).to receive(:map).and_return(map)
  29. result = process(old)
  30. expect(result.keys.size).to eq 2
  31. expect(result[:new_key]).to eq old[:old_key]
  32. expect(result[:new_second]).to eq old[:second]
  33. end
  34. end